提交 8c45d0b1 编写于 作者: aaronchen2k2k's avatar aaronchen2k2k

update help

上级 53de14a0
......@@ -5,12 +5,10 @@ version: 1.0
fields:
- field: field0
note:
range: a-z
loop: 3
- field: field1
note: 测试自定义字段
from: numb.yaml
use: small,large
loop: 3
......@@ -22,7 +20,6 @@ fields:
loop: 3
- field: field3
note: 测试Excel数据
from: system.address.v1.city
select: name
where: state like '%山东%'
\ No newline at end of file
$>zd.exe -s 根据系统提示,设置工具语言属性。
$>zd.exe -y sample/test.yaml -c 15 -field field1 -o sample/output.txt -f text
执行数据生成命令。使用配置文件sample/test.yaml,生成15行数据,以text格式的输出到sample/output.txt文件中。
$>zd.exe -d sample/common.yaml -y sample/test.yaml -c 15 -field field1 -o sample/output.txt -f text
执行数据生成命令。使用文件sample/test.yam覆盖默认配置sample/common.yaml中的内容。
\ No newline at end of file
$>zd.exe -y demo/test.yaml -c 15 -field field1 -o demo/output.txt -f text
执行数据生成命令。使用配置文件demo/test.yaml,生成15行数据,以text格式的输出到demo/output.txt文件中。
$>zd.exe -d demo/common.yaml -y demo/test.yaml -c 15 -field field1 -o demo/output.txt -f text
执行数据生成命令。使用文件demo/test.yam覆盖默认配置demo/common.yaml中的内容。
\ No newline at end of file
-help -h 查看帮助信息。
-set -s 设置工具语言属性。用户对当前目录需要有写权限。
-h --help 查看帮助信息。
-s --set 设置工具语言属性。用户对当前目录需要有写权限。
默认根据定义文件生成数据。
-d -default 默认定义文件
-y -yaml 指定定义文件
-c -count 指定生成数据的条数
-field 需要输出的字段,用逗号分隔。未指定时,默认输出-yaml文件中的所有字段。
-o -out 指定输出文件
-f format 输出格式,支持text、json、xml和sql语句,默认为text。
-t -table 输出格式为table时,用于指定insert语句的表名
-d --default 默认定义文件
-y --yaml 指定定义文件
-c --count 指定生成数据的条数
--field 需要输出的字段,用逗号分隔。未指定时,默认输出-yaml文件中的所有字段。
-o --out 指定输出文件
-f --format 输出格式,支持text、json、xml和sql语句,默认为text。
-t --table 输出格式为table时,用于指定insert语句的表名
--verbose 增加此参数,显示详细调试信息。
为了方便在任意目录中执行%s命令,建议将其加入环境变量中,具体方法参照以下地址。
......
此差异已折叠。
......@@ -25,7 +25,9 @@ func Generate(deflt string, yml string, total int, fieldsToExportStr string, out
rows, colTypes := gen.GenerateForDefinition(deflt, yml, fieldsToExport, total)
content := Print(rows, format, table, colTypes, fieldsToExport)
WriteToFile(out, content)
if out != "" {
WriteToFile(out, content)
}
entTime := time.Now().Unix()
logUtils.Screen(i118Utils.I118Prt.Sprintf("generate_records", len(rows), out, entTime - startTime ))
......
......@@ -32,9 +32,15 @@ func ParseSql(file string, out string) {
}
bytes, _ := yaml.Marshal(&def)
out = fileUtils.UpdateDir(out)
outFile := out + tableName + ".yaml"
WriteToFile(outFile, string(bytes))
content := string(bytes)
if out != "" {
out = fileUtils.UpdateDir(out)
outFile := out + tableName + ".yaml"
WriteToFile(outFile, content)
} else {
logUtils.Screen(content)
}
}
entTime := time.Now().Unix()
......
......@@ -43,7 +43,7 @@ func main() {
flagSet = flag.NewFlagSet("zd", flag.ContinueOnError)
flagSet.StringVar(&deflt, "d", "", "")
flagSet.StringVar(&deflt, "deflt", "", "")
flagSet.StringVar(&deflt, "default", "", "")
flagSet.StringVar(&yml, "y", "", "")
flagSet.StringVar(&yml, "yml", "", "")
......@@ -80,7 +80,7 @@ func main() {
switch os.Args[1] {
case "-s", "-set":
action.Set()
set()
case "-h", "-help":
logUtils.PrintUsage()
default:
......@@ -88,6 +88,10 @@ func main() {
}
}
func set() {
action.Set()
}
func gen(args []string) {
if err := flagSet.Parse(args[2:]); err == nil {
if input != "" {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册