Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
LinuxSuRen
zendata
提交
c3f5adfe
Z
zendata
项目概览
LinuxSuRen
/
zendata
与 Fork 源项目一致
Fork自
易企天创 / zendata
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Z
zendata
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
c3f5adfe
编写于
8月 19, 2020
作者:
aaronchen2k2k
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
implement task#7667
上级
21db7cc1
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
55 addition
and
20 deletion
+55
-20
res/en/messages.json
res/en/messages.json
+8
-4
res/zh/messages.json
res/zh/messages.json
+8
-4
src/utils/config/config.go
src/utils/config/config.go
+39
-12
未找到文件。
res/en/messages.json
浏览文件 @
c3f5adfe
...
...
@@ -27,16 +27,20 @@
"translation"
:
"1) 请选择您要使用的语言,中文请输入数字1。
\n
2) Please select the language. Input 2 for English."
},
{
"id"
:
"add_to_path"
,
"translation"
:
"Would you like to add ZenData to PATH environment variable? (y/n, default is Yes)"
"id"
:
"add_to_path_win"
,
"translation"
:
"Would you like to add zd.exe to $PATH environment variable? (y/n, default is Yes)"
},
{
"id"
:
"add_to_path_linux"
,
"translation"
:
"Would you like to add zd command to $PATH environment variable? (y/n, default is Yes)"
},
{
"id"
:
"add_to_path_success_win"
,
"translation"
:
"Success to add PATH environment variable, please reopen the command window."
"translation"
:
"Success to add
$
PATH environment variable, please reopen the command window."
},
{
"id"
:
"add_to_path_success_linux"
,
"translation"
:
"Success to add PATH environment variable, please execute 'source %s' to make it effective."
"translation"
:
"Success to add
$
PATH environment variable, please execute 'source %s' to make it effective."
},
{
"id"
:
"current_config"
,
...
...
res/zh/messages.json
浏览文件 @
c3f5adfe
...
...
@@ -22,16 +22,20 @@
"translation"
:
"1) 请选择您要使用的语言,中文请输入数字1。
\n
2) Please select the language. Input 2 for English."
},
{
"id"
:
"add_to_path"
,
"translation"
:
"是否将ZenData加入Path环境变量,以方便在任何目录中执行?(y/n, 默认Yes)"
"id"
:
"add_to_path_win"
,
"translation"
:
"是否将zd.exe加入$Path环境变量,以方便在任何目录中执行?(y/n, 默认Yes)"
},
{
"id"
:
"add_to_path_linux"
,
"translation"
:
"是否将zd命令加入$Path环境变量,以方便在任何目录中执行?(y/n, 默认Yes)"
},
{
"id"
:
"add_to_path_success_win"
,
"translation"
:
"成功
设置
PATH环境变量,请重新打开命令行窗口。"
"translation"
:
"成功
加入$
PATH环境变量,请重新打开命令行窗口。"
},
{
"id"
:
"add_to_path_success_linux"
,
"translation"
:
"成功
设置
PATH环境变量,请执行source %s使其生效。"
"translation"
:
"成功
加入$
PATH环境变量,请执行source %s使其生效。"
},
{
"id"
:
"current_config"
,
...
...
src/utils/config/config.go
浏览文件 @
c3f5adfe
...
...
@@ -145,7 +145,12 @@ func InputForSet() {
// set PATH environment vari
var
addToPath
bool
stdinUtils
.
InputForBool
(
&
addToPath
,
true
,
"add_to_path"
)
if
commonUtils
.
IsWin
()
{
stdinUtils
.
InputForBool
(
&
addToPath
,
true
,
"add_to_path_win"
)
}
else
{
stdinUtils
.
InputForBool
(
&
addToPath
,
true
,
"add_to_path_linux"
)
}
if
addToPath
{
AddZdToPath
()
}
...
...
@@ -159,22 +164,44 @@ func AddZdToPath() {
home
:=
userProfile
.
HomeDir
if
commonUtils
.
IsWin
()
{
addZdToPathWin
(
home
)
}
else
{
addZdToPathLinux
(
home
)
}
}
func
addZdToPathWin
(
home
string
)
{
pathVar
:=
os
.
Getenv
(
"PATH"
)
if
strings
.
Contains
(
pathVar
,
vari
.
ExeDir
)
{
return
}
cmd
:=
fmt
.
Sprintf
(
"setx PATH
\"
%%PATH%%;%s
\"
/m"
,
vari
.
ExeDir
)
out
,
err
:=
shellUtils
.
ExeShell
(
cmd
)
if
err
==
nil
{
msg
:=
i118Utils
.
I118Prt
.
Sprintf
(
"add_to_path_success_win"
)
logUtils
.
PrintToWithColor
(
msg
,
color
.
FgRed
)
}
else
{
path
:=
fmt
.
Sprintf
(
"%s%s%s"
,
home
,
constant
.
PthSep
,
".bash_profile"
)
logUtils
.
PrintToWithColor
(
i118Utils
.
I118Prt
.
Sprintf
(
"fail_to_exec_cmd"
,
cmd
,
err
.
Error
()
+
": "
+
out
),
color
.
FgRed
)
}
}
content
:=
fileUtils
.
ReadFile
(
path
)
if
strings
.
Contains
(
content
,
vari
.
ExeDir
)
{
return
}
func
addZdToPathLinux
(
home
string
)
{
path
:=
fmt
.
Sprintf
(
"%s%s%s"
,
home
,
constant
.
PthSep
,
".bash_profile"
)
cmd
:=
fmt
.
Sprintf
(
"echo 'export PATH=$PATH:%s' >> %s"
,
vari
.
ExeDir
,
path
)
out
,
err
:=
shellUtils
.
ExeShell
(
cmd
)
content
:=
fileUtils
.
ReadFile
(
path
)
if
strings
.
Contains
(
content
,
vari
.
ExeDir
)
{
return
}
if
err
==
nil
{
logUtils
.
PrintToWithColor
(
i118Utils
.
I118Prt
.
Sprintf
(
"add_to_path_success_linux"
,
path
),
color
.
FgRed
)
}
else
{
logUtils
.
PrintToWithColor
(
i118Utils
.
I118Prt
.
Sprintf
(
"fail_to_exec_cmd"
,
cmd
,
err
.
Error
()
+
": "
+
out
),
color
.
FgRed
)
}
cmd
:=
fmt
.
Sprintf
(
"echo 'export PATH=$PATH:%s' >> %s"
,
vari
.
ExeDir
,
path
)
out
,
err
:=
shellUtils
.
ExeShell
(
cmd
)
if
err
==
nil
{
msg
:=
i118Utils
.
I118Prt
.
Sprintf
(
"add_to_path_success_linux"
,
path
)
logUtils
.
PrintToWithColor
(
msg
,
color
.
FgRed
)
}
else
{
logUtils
.
PrintToWithColor
(
i118Utils
.
I118Prt
.
Sprintf
(
"fail_to_exec_cmd"
,
cmd
,
err
.
Error
()
+
": "
+
out
),
color
.
FgRed
)
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录