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

fix issues

上级 817d708f
......@@ -30,3 +30,4 @@
/runtime/protobuf/out/
/users/common/
*.exe
/tmp/cache/.data.db
Version = 2.2
Version = 2.2
Language = zh
......@@ -114,9 +114,6 @@ func main() {
flagSet.BoolVar(&example, "e", false, "")
flagSet.BoolVar(&example, "example", false, "")
flagSet.BoolVar(&help, "h", false, "")
flagSet.BoolVar(&help, "help", false, "")
flagSet.BoolVar(&set, "S", false, "")
flagSet.BoolVar(&set, "set", false, "")
......@@ -131,6 +128,9 @@ func main() {
flagSet.BoolVar(&vari.Verbose, "verbose", false, "")
flagSet.BoolVar(&help, "h", false, "")
flagSet.BoolVar(&help, "help", false, "")
if len(os.Args) == 1 {
os.Args = append(os.Args, "-help")
}
......
......@@ -104,9 +104,9 @@ fields:
range: user.txt:R # 相对当前文件路径。
postfix: "\t"
# - field: field_yaml # 引用其他的定义文件整体内容。
# range: 01_range.yaml{3} # 相对当前文件路径。
# postfix: "\t"
- field: field_yaml # 引用其他的定义文件整体内容。
range: 01_range.yaml{3} # 相对当前文件路径。
postfix: "\t"
- field: field_use_config # 引用其他的config定义文件。
config: number.yaml # 相对当前文件路径,config内包含单个字段。
......
title: zendata数据配置语法说明
desc:
author: zentao
title: range
desc: 描述
version: 1.0
fields:
- field: f1
from: uuid.v1.yaml
use: by_format
range: 1-6
postfix: "\t"
- field: nesting1
postfix: "\t"
union: true
fields:
- field: child1
range: A-C
prefix: part1_
postfix: ' | '
- field: child2
range: 1-9
prefix: part2_
- field: nesting2
fields:
- field: child1
range: A-C
prefix: part1_
postfix: ' | '
- field: f2
from: ulid.v1.yaml
use: ulid{3}
\ No newline at end of file
- field: child2
range: 1-9
prefix: part2_
\ No newline at end of file
......@@ -14,9 +14,9 @@ import (
)
var (
configs []string
defaultFile string
configFile string
configs []string
defaultFile string
configFile string
defaultDefContent []byte
configDefContent []byte
......@@ -61,6 +61,8 @@ func DataHandler(writer http.ResponseWriter, req *http.Request) {
defaultFile = ""
configFile = ""
}
//writer.WriteHeader(http.StatusAccepted)
}
func genData() {
......@@ -85,4 +87,4 @@ func genData() {
dur := tmEnd.Unix() - tmStart.Unix()
logUtils.PrintTo(fmt.Sprintf("Duriation %d sec.", dur))
}
}
\ No newline at end of file
}
......@@ -13,7 +13,7 @@ import (
"time"
)
func Generate(files []string, fieldsToExportStr, format, table string) {
func Generate(files []string, fieldsToExportStr, format, table string) (lines []interface{}) {
startTime := time.Now().Unix()
if len(files) == 0 {
return
......@@ -28,7 +28,7 @@ func Generate(files []string, fieldsToExportStr, format, table string) {
vari.ConfigFileDir = fileUtils.GetAbsDir(files[1])
}
contents := gen.LoadFilesContents(files)
GenerateByContent(contents, fieldsToExportStr, format, table)
lines = GenerateByContent(contents, fieldsToExportStr, format, table)
} else { // gen from protobuf
buf, pth := gen.GenerateFromProtobuf(files[0])
......@@ -94,7 +94,7 @@ func GenerateByContent(contents [][]byte, fieldsToExportStr, format, table strin
}
if !isFromExcel(format) { // returned is for preview, sql exec and article writing
lines = gen.Print(rows, format, table, colIsNumArr, fieldsToExport)
lines = gen.PrintLines(rows, format, table, colIsNumArr, fieldsToExport)
} else { // for Excel and cvs
gen.Write(rows, table, colIsNumArr, fieldsToExport)
}
......
......@@ -349,7 +349,7 @@ func CreateValuesFromYaml(field *model.DefField, yamlFile, stepStr string, repea
rows = randomValuesArr(rows)
}
items = Print(rows, constant.FormatData, "", colIsNumArr, fieldsToExport)
items = PrintLines(rows, constant.FormatData, "", colIsNumArr, fieldsToExport)
if repeat > 0 {
if repeat > len(items) {
......
......@@ -14,7 +14,7 @@ import (
"github.com/easysoft/zendata/pkg/utils/vari"
)
func Print(rows [][]string, format string, table string, colIsNumArr []bool,
func PrintLines(rows [][]string, format string, table string, colIsNumArr []bool,
fields []string) (lines []interface{}) {
var sqlHeader string
......
......@@ -55,6 +55,7 @@ type DefField struct {
RightPad string `yaml:"rightpad,omitempty"`
Path string `yaml:"path,omitempty"`
FileDir string `yaml:"fileDir,omitempty"`
Union bool `yaml:"union,omitempty"`
Froms []DefField `yaml:"froms,flow,omitempty"`
}
......
......@@ -51,7 +51,7 @@ func PrintUsage() {
regx, _ = regexp.Compile(`zd.exe`)
usage = regx.ReplaceAllString(usage, "zd")
regx, _ = regexp.Compile(`d:/zd/config `)
regx, _ = regexp.Compile(`d:\zd\config `)
usage = regx.ReplaceAllString(usage, "/home/user/zd/config")
}
fmt.Printf("%s\n", usage)
......
......@@ -67,6 +67,6 @@ $zd.exe -p 80 -R d:\zd\config # Listen port 80. Use d:\zd\config as th
Client Call:
$curl http:\\localhost:8848\?d=demo\default.yaml&c=demo\config.yaml&n=100&T=true # Specify the server config file via GET.
$curl http:\\localhost:8848\?default=demo\default.yaml&output=test.sql&table=user # Parameter names can be full.
$curl -i -X POST http:\\localhost:8848?lines=3 -F default=@demo\default.yaml # The config can be uploaded via POST.
$curl http://localhost:8848/data?d=demo/default.yaml&c=demo/config.yaml&n=100&T=true # Specify the server config file via GET.
$curl http://localhost:8848/data?default=demo/default.yaml&output=test.sql&table=user # Parameter names can be full.
$curl -i -X POST http://localhost:8848/data?lines=3 -F default=@demo/default.yaml # The config can be uploaded via POST.
......@@ -62,6 +62,6 @@ $zd.exe -p 80 -R d:\zd\config # 监听80
客户端调用:
$curl http://localhost:8848/?d=demo/default.yaml&c=demo/config.yaml&n=100&T=true # 通过GET方式指定服务器端配置文件。
$curl http://localhost:8848/?default=demo/default.yaml&output=test.sql&table=user # 参数名可以用全拼。
$curl -i -X POST http://localhost:8848?lines=3 -F default=@demo/default.yaml # 可以通过POST方式上传配置文件。
$curl http://localhost:8848/data?d=demo/default.yaml&c=demo/config.yaml&n=100&T=true # 通过GET方式指定服务器端配置文件。
$curl http://localhost:8848/data?default=demo/default.yaml&output=test.sql&table=user # 参数名可以用全拼。
$curl -i -X POST http://localhost:8848/data?lines=3 -F default=@demo/default.yaml # 可以通过POST方式上传配置文件。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册