Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
LinuxSuRen
zendata
提交
3e0915cd
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,发现更多精彩内容 >>
提交
3e0915cd
编写于
8月 19, 2020
作者:
aaronchen2k2k
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
close task#7668
上级
eec2ab07
变更
8
展开全部
显示空白变更内容
内联
并排
Showing
8 changed file
with
107 addition
and
13 deletion
+107
-13
demo/default.yaml
demo/default.yaml
+4
-4
res/en/messages.json
res/en/messages.json
+16
-0
res/res.go
res/res.go
+3
-3
res/zh/messages.json
res/zh/messages.json
+16
-0
src/utils/config/config.go
src/utils/config/config.go
+43
-3
src/utils/file/file.go
src/utils/file/file.go
+1
-1
src/utils/shell/shell.go
src/utils/shell/shell.go
+1
-2
src/utils/stdin/stdin.go
src/utils/stdin/stdin.go
+23
-0
未找到文件。
demo/default.yaml
浏览文件 @
3e0915cd
...
...
@@ -102,23 +102,23 @@ fields:
postfix
:
"
\t
"
-
field
:
field_use_ranges
# 引用內置的定义文件,该文件定义了多个range,他们共享了一些field层面的属性。
from
:
users.jenkins.number.v1.yaml
# 引用data/custom/number/v1.yaml文件里面的ranges定义。
from
:
custom.test.number.v1.yaml
# 引用data/custom/number/v1.yaml文件里面的ranges定义。
use
:
medium
# 使用该文件中定义的medium分组。
postfix
:
"
\t
"
-
field
:
field_use_instance
# 引用其他的定义文件,该文件定义了多个实例。
from
:
yaml.ip.v1.yaml
# 引用data/system/ip/v1.yaml
from
:
system.ip.v1.yaml
# 引用data/system/ip/v1.yaml
use
:
privateC,privateB
# 使用该文件中定义的privateC和privateB两个实例。
postfix
:
"
\t
"
-
field
:
field_nested_instant
# 引用其他的定义文件,且该文件引用了其他实例。
from
:
users.jenkins.ip.private.yaml
# 引用data/custom/ip/private.yaml
from
:
custom.ip.private.yaml
# 引用data/custom/ip/private.yaml
use
:
all
# 使用该文件中的所有实例。
prefix
:
"
{"
postfix
:
"
}"
-
field
:
field_use_excel
# 从excel数据源里面取数据。
from
:
address.cn.v1.china
# 从data/address/cn.
v1.xlsx文件中读取名为china的工作簿。
from
:
system.address.v1.china
# 从data/system/address/
v1.xlsx文件中读取名为china的工作簿。
select
:
city
# 查询city字段。
where
:
state like '%山东%'
# 条件是省份包含山东。
postfix
:
"
\t
"
...
...
res/en/messages.json
浏览文件 @
3e0915cd
...
...
@@ -26,6 +26,18 @@
"id"
:
"enter_language"
,
"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_success_win"
,
"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."
},
{
"id"
:
"current_config"
,
"translation"
:
"Current config:"
...
...
@@ -132,6 +144,10 @@
{
"id"
:
"fail_to_generate_field"
,
"translation"
:
"Fail to generate data for field '%s'."
},
{
"id"
:
"fail_to_exec_cmd"
,
"translation"
:
"Fail to exec command '%s', error is '%s'."
}
]
}
\ No newline at end of file
res/res.go
浏览文件 @
3e0915cd
此差异已折叠。
点击以展开。
res/zh/messages.json
浏览文件 @
3e0915cd
...
...
@@ -21,6 +21,18 @@
"id"
:
"enter_language"
,
"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_success_win"
,
"translation"
:
"成功设置PATH环境变量,请重新打开命令行窗口。"
},
{
"id"
:
"add_to_path_success_linux"
,
"translation"
:
"成功设置PATH环境变量,请执行source %s使其生效。"
},
{
"id"
:
"current_config"
,
"translation"
:
"当前配置:"
...
...
@@ -123,6 +135,10 @@
{
"id"
:
"fail_to_generate_field"
,
"translation"
:
"为Field %s生成数据失败。"
},
{
"id"
:
"fail_to_exec_cmd"
,
"translation"
:
"执行命令'%s'失败,错误消息为'%s'。"
}
]
}
\ No newline at end of file
src/utils/config/config.go
浏览文件 @
3e0915cd
...
...
@@ -14,8 +14,10 @@ import (
"github.com/fatih/color"
"gopkg.in/ini.v1"
"os"
"os/user"
"path/filepath"
"reflect"
"strings"
)
func
InitConfig
()
{
...
...
@@ -133,14 +135,52 @@ func InputForSet() {
numb
=
"2"
}
numbSelected
:=
stdinUtils
.
GetInput
(
"(1|2)"
,
numb
,
"enter_language"
,
enCheck
,
zhCheck
)
if
numbSelected
==
"1"
{
// set lang
langNo
:=
stdinUtils
.
GetInput
(
"(1|2)"
,
numb
,
"enter_language"
,
enCheck
,
zhCheck
)
if
langNo
==
"1"
{
conf
.
Language
=
"zh"
}
else
{
conf
.
Language
=
"en"
}
// set PATH environment vari
var
addToPath
bool
stdinUtils
.
InputForBool
(
&
addToPath
,
true
,
"add_to_path"
)
if
addToPath
{
AddZdToPath
()
}
SaveConfig
(
conf
)
PrintCurrConfig
()
}
func
AddZdToPath
()
{
userProfile
,
_
:=
user
.
Current
()
home
:=
userProfile
.
HomeDir
if
commonUtils
.
IsWin
()
{
}
else
{
path
:=
fmt
.
Sprintf
(
"%s%s%s"
,
home
,
constant
.
PthSep
,
".bash_profile"
)
content
:=
fileUtils
.
ReadFile
(
path
)
if
strings
.
Contains
(
content
,
vari
.
ExeDir
)
{
return
}
cmd
:=
fmt
.
Sprintf
(
"echo 'export PATH=$PATH:%s' >> %s"
,
vari
.
ExeDir
,
path
)
out
,
err
:=
shellUtils
.
ExeShell
(
cmd
)
if
err
==
nil
{
msg
:=
""
if
commonUtils
.
IsWin
()
{
msg
=
i118Utils
.
I118Prt
.
Sprintf
(
"add_to_path_success_win"
)
}
else
{
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
)
}
}
}
src/utils/file/file.go
浏览文件 @
3e0915cd
src/utils/shell/shell.go
浏览文件 @
3e0915cd
...
...
@@ -5,7 +5,6 @@ import (
"bytes"
"fmt"
commonUtils
"github.com/easysoft/zendata/src/utils/common"
logUtils
"github.com/easysoft/zendata/src/utils/log"
"io"
"os/exec"
"strings"
...
...
@@ -57,7 +56,7 @@ func ExeShellWithOutput(cmdStr string) []string {
if
err2
!=
nil
||
io
.
EOF
==
err2
{
break
}
logUtils
.
PrintTo
(
strings
.
TrimRight
(
line
,
"
\n
"
))
fmt
.
Println
(
strings
.
TrimRight
(
line
,
"
\n
"
))
output
=
append
(
output
,
line
)
}
...
...
src/utils/stdin/stdin.go
浏览文件 @
3e0915cd
...
...
@@ -60,6 +60,29 @@ func GetInput(regx string, defaultVal string, fmtStr string, params ...interface
}
}
func
InputForBool
(
in
*
bool
,
defaultVal
bool
,
fmtStr
string
,
fmtParam
...
interface
{})
{
str
:=
GetInput
(
"(yes|no|y|n|)"
,
""
,
fmtStr
,
fmtParam
...
)
if
str
==
""
{
*
in
=
defaultVal
msg
:=
""
if
*
in
{
msg
=
"yes"
}
else
{
msg
=
"no"
}
logUtils
.
PrintTo
(
msg
)
return
}
if
str
==
"y"
&&
str
!=
"yes"
{
*
in
=
true
}
else
{
*
in
=
false
}
}
func
Scanf
(
a
*
string
)
{
reader
:=
bufio
.
NewReader
(
os
.
Stdin
)
data
,
_
,
_
:=
reader
.
ReadLine
()
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录