Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
LinuxSuRen
zendata
提交
ab1051c3
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 搜索 >>
提交
ab1051c3
编写于
8月 06, 2020
作者:
aaronchen2k2k
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
create output dir if needed
上级
c716fe34
变更
12
隐藏空白更改
内联
并排
Showing
12 changed file
with
102 addition
and
9 deletion
+102
-9
src/zd.go
src/zd.go
+2
-0
test/ztf/script/basic/field_common.php
test/ztf/script/basic/field_common.php
+1
-1
test/ztf/script/cmd/cmd_decode.exp
test/ztf/script/cmd/cmd_decode.exp
+2
-0
test/ztf/script/cmd/cmd_decode.php
test/ztf/script/cmd/cmd_decode.php
+25
-0
test/ztf/script/cmd/cmd_example.php
test/ztf/script/cmd/cmd_example.php
+1
-1
test/ztf/script/cmd/cmd_i118.php
test/ztf/script/cmd/cmd_i118.php
+1
-1
test/ztf/script/cmd/cmd_list.php
test/ztf/script/cmd/cmd_list.php
+1
-1
test/ztf/script/cmd/cmd_sql.exp
test/ztf/script/cmd/cmd_sql.exp
+1
-0
test/ztf/script/cmd/cmd_sql.php
test/ztf/script/cmd/cmd_sql.php
+23
-0
test/ztf/script/cmd/cmd_usage.php
test/ztf/script/cmd/cmd_usage.php
+1
-1
test/ztf/script/cmd/cmd_view.php
test/ztf/script/cmd/cmd_view.php
+1
-1
test/ztf/script/lib/zd.php
test/ztf/script/lib/zd.php
+43
-3
未找到文件。
src/zd.go
浏览文件 @
ab1051c3
...
...
@@ -19,6 +19,7 @@ import (
"os"
"os/signal"
"path"
"path/filepath"
"strconv"
"strings"
"syscall"
...
...
@@ -187,6 +188,7 @@ func toGen() {
}
if
output
!=
""
{
fileUtils
.
MkDirIfNeeded
(
filepath
.
Dir
(
output
))
fileUtils
.
RemoveExist
(
output
)
action
.
FileWriter
,
_
=
os
.
OpenFile
(
output
,
os
.
O_RDWR
|
os
.
O_CREATE
,
0777
)
defer
action
.
FileWriter
.
Close
()
...
...
test/ztf/script/basic/field_common.php
浏览文件 @
ab1051c3
...
...
@@ -13,7 +13,7 @@ pid=0
[esac]
*/
include_once
__DIR__
.
DIRECTORY_SEPARATOR
.
'../
common
/zd.php'
;
include_once
__DIR__
.
DIRECTORY_SEPARATOR
.
'../
lib
/zd.php'
;
$zd
=
new
zendata
();
$output
=
$zd
->
create
(
""
,
"default.yaml"
,
3
,
""
,
array
(
"fields"
=>
"field_common"
));
...
...
test/ztf/script/cmd/cmd_decode.exp
0 → 100644
浏览文件 @
ab1051c3
>> 3
>> int_1
\ No newline at end of file
test/ztf/script/cmd/cmd_decode.php
0 → 100755
浏览文件 @
ab1051c3
#!/usr/bin/env php
<?php
/**
[case]
title=
cid=0
pid=0
[group]
>>
>>
[esac]
*/
include_once
__DIR__
.
DIRECTORY_SEPARATOR
.
'../lib/zd.php'
;
$zd
=
new
zendata
();
$output
=
$zd
->
create
(
""
,
"test2.yaml"
,
3
,
"output/test2.txt"
);
$zd
->
decode
(
"test2.yaml"
,
"output/test2.txt"
,
"output/test2.json"
);
$lineArr
=
$zd
->
readOutput
(
"output/zt_action.yaml"
,
array
(
6
));
$lines
=
join
(
"
\n
"
,
$lineArr
);
print
(
">>
$lines
\n
"
);
\ No newline at end of file
test/ztf/script/cmd/cmd_example.php
浏览文件 @
ab1051c3
...
...
@@ -13,7 +13,7 @@ pid=0
[esac]
*/
include_once
__DIR__
.
DIRECTORY_SEPARATOR
.
'../
common
/zd.php'
;
include_once
__DIR__
.
DIRECTORY_SEPARATOR
.
'../
lib
/zd.php'
;
$zd
=
new
zendata
();
...
...
test/ztf/script/cmd/cmd_i118.php
浏览文件 @
ab1051c3
...
...
@@ -15,7 +15,7 @@ pid=0
[esac]
*/
include_once
__DIR__
.
DIRECTORY_SEPARATOR
.
'../
common
/zd.php'
;
include_once
__DIR__
.
DIRECTORY_SEPARATOR
.
'../
lib
/zd.php'
;
$zd
=
new
zendata
();
...
...
test/ztf/script/cmd/cmd_list.php
浏览文件 @
ab1051c3
...
...
@@ -14,7 +14,7 @@ pid=0
[esac]
*/
include_once
__DIR__
.
DIRECTORY_SEPARATOR
.
'../
common
/zd.php'
;
include_once
__DIR__
.
DIRECTORY_SEPARATOR
.
'../
lib
/zd.php'
;
$zd
=
new
zendata
();
...
...
test/ztf/script/cmd/cmd_sql.exp
0 → 100644
浏览文件 @
ab1051c3
>> - field: id
\ No newline at end of file
test/ztf/script/cmd/cmd_sql.php
0 → 100755
浏览文件 @
ab1051c3
#!/usr/bin/env php
<?php
/**
[case]
title=
cid=0
pid=0
[group]
>>
>>
[esac]
*/
include_once
__DIR__
.
DIRECTORY_SEPARATOR
.
'../lib/zd.php'
;
$zd
=
new
zendata
();
$output
=
$zd
->
convertSql
(
"zentao.sql"
,
"output"
);
$lineArr
=
$zd
->
readOutput
(
"output/zt_action.yaml"
,
array
(
6
));
$lines
=
join
(
"
\n
"
,
$lineArr
);
print
(
">>
$lines
\n
"
);
\ No newline at end of file
test/ztf/script/cmd/cmd_usage.php
浏览文件 @
ab1051c3
...
...
@@ -14,7 +14,7 @@ pid=0
[esac]
*/
include_once
__DIR__
.
DIRECTORY_SEPARATOR
.
'../
common
/zd.php'
;
include_once
__DIR__
.
DIRECTORY_SEPARATOR
.
'../
lib
/zd.php'
;
$zd
=
new
zendata
();
...
...
test/ztf/script/cmd/cmd_view.php
浏览文件 @
ab1051c3
...
...
@@ -13,7 +13,7 @@ pid=0
[esac]
*/
include_once
__DIR__
.
DIRECTORY_SEPARATOR
.
'../
common
/zd.php'
;
include_once
__DIR__
.
DIRECTORY_SEPARATOR
.
'../
lib
/zd.php'
;
$zd
=
new
zendata
();
...
...
test/ztf/script/lib/zd.php
浏览文件 @
ab1051c3
...
...
@@ -17,8 +17,14 @@ class zendata
public
function
create
(
$default
,
$conf
,
$lines
,
$output
,
$options
=
array
())
{
$cmdStr
=
sprintf
(
"%s -c %s/%s -n %d -F %s"
,
$this
->
cmdPath
,
$this
->
workDir
,
$conf
,
$lines
,
$options
[
"fields"
]);
$cmdStr
=
sprintf
(
"%s -c %s/%s -n %d"
,
$this
->
cmdPath
,
$this
->
workDir
,
$conf
,
$lines
);
if
(
count
(
$options
)
>
0
&&
$options
[
"fields"
])
{
$cmdStr
.
=
" -F "
.
$options
[
"fields"
];
}
if
(
$output
)
{
$cmdStr
.
=
" -o "
.
$this
->
workDir
.
"/"
.
$output
;
}
print
(
"
$cmdStr
\n
"
);
$output
=
[];
...
...
@@ -26,8 +32,42 @@ class zendata
return
$output
;
}
public
function
parse
(
$config
,
$input
)
public
function
convertSql
(
$file
,
$dir
,
$options
=
array
()
)
{
$cmdStr
=
sprintf
(
"%s -i %s/%s -o %s/%s"
,
$this
->
cmdPath
,
$this
->
workDir
,
$file
,
$this
->
workDir
,
$dir
);
print
(
"
$cmdStr
\n
"
);
$output
=
[];
exec
(
$cmdStr
,
$output
);
return
$output
;
}
public
function
readOutput
(
$file
,
$lines
=
array
())
{
$filePath
=
sprintf
(
"%s/%s"
,
$this
->
workDir
,
$file
);
print
(
"
$filePath
\n
"
);
$content
=
file_get_contents
(
$filePath
);
if
(
count
(
$lines
)
==
0
)
{
return
$content
;
}
$ret
=
array
();
$arr
=
explode
(
"
\n
"
,
$content
);
foreach
(
$lines
as
$num
)
{
array_push
(
$ret
,
$arr
[
$num
-
1
]);
}
return
$ret
;
}
public
function
decode
(
$config
,
$input
,
$out
)
{
$cmdStr
=
sprintf
(
"-D -c %s/%s -i %s/%s -o %s/%s"
,
$this
->
cmdPath
,
$this
->
workDir
,
$config
,
$this
->
workDir
,
$input
,
$this
->
workDir
,
$out
);
print
(
"
$cmdStr
\n
"
);
exec
(
$cmdStr
,
$output
);
}
public
function
cmd
(
$params
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录