Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
易企天创
zentaoatf
提交
bd4d48f8
Z
zentaoatf
项目概览
易企天创
/
zentaoatf
9 个月 前同步成功
通知
11
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
3
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Z
zentaoatf
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
3
Issue
3
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
bd4d48f8
编写于
9月 04, 2019
作者:
aaronchen2k2k
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
tips
上级
2bbfb6c2
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
96 addition
and
106 deletion
+96
-106
src/action/gen.go
src/action/gen.go
+1
-1
src/action/run.go
src/action/run.go
+2
-3
src/action/set.go
src/action/set.go
+78
-0
src/atf.go
src/atf.go
+1
-2
src/utils/stdin/stdin.go
src/utils/stdin/stdin.go
+14
-100
未找到文件。
src/action/gen.go
浏览文件 @
bd4d48f8
...
...
@@ -14,7 +14,7 @@ import (
func
Generate
(
productId
string
,
moduleId
string
,
suiteId
string
,
taskId
string
,
independentFile
bool
,
scriptLang
string
)
{
stdinUtils
.
CheckRequestConfig
()
CheckRequestConfig
()
if
(
productId
!=
""
)
||
(
moduleId
!=
""
&&
productId
!=
""
)
||
suiteId
!=
""
||
taskId
!=
""
{
...
...
src/action/run.go
浏览文件 @
bd4d48f8
...
...
@@ -10,7 +10,6 @@ import (
fileUtils
"github.com/easysoft/zentaoatf/src/utils/file"
i118Utils
"github.com/easysoft/zentaoatf/src/utils/i118"
logUtils
"github.com/easysoft/zentaoatf/src/utils/log"
stdinUtils
"github.com/easysoft/zentaoatf/src/utils/stdin"
"github.com/easysoft/zentaoatf/src/utils/vari"
zentaoUtils
"github.com/easysoft/zentaoatf/src/utils/zentao"
"path"
...
...
@@ -66,7 +65,7 @@ func getCaseByTaskId(id string, dir string) []string {
taskId
,
err
:=
strconv
.
Atoi
(
id
)
if
err
==
nil
&&
taskId
>
0
{
stdinUtils
.
CheckRequestConfig
()
CheckRequestConfig
()
zentaoService
.
GetCaseIdsByTask
(
id
,
&
caseIdMap
)
}
...
...
@@ -80,7 +79,7 @@ func getCaseBySuiteId(id string, dir string) []string {
suiteId
,
err
:=
strconv
.
Atoi
(
id
)
if
err
==
nil
&&
suiteId
>
0
{
stdinUtils
.
CheckRequestConfig
()
CheckRequestConfig
()
zentaoService
.
GetCaseIdsBySuite
(
id
,
&
caseIdMap
)
}
...
...
src/action/set.go
浏览文件 @
bd4d48f8
package
action
import
(
"fmt"
configUtils
"github.com/easysoft/zentaoatf/src/utils/config"
i118Utils
"github.com/easysoft/zentaoatf/src/utils/i118"
stdinUtils
"github.com/easysoft/zentaoatf/src/utils/stdin"
)
func
InputForSet
()
{
conf
:=
configUtils
.
ReadCurrConfig
()
var
configSite
bool
language
:=
""
url
:=
""
account
:=
""
password
:=
""
fmt
.
Println
(
i118Utils
.
I118Prt
.
Sprintf
(
"begin_config"
))
enCheck
:=
""
var
numb
string
if
conf
.
Language
==
"en"
{
enCheck
=
"*"
numb
=
"1"
}
zhCheck
:=
""
if
conf
.
Language
==
"zh"
{
zhCheck
=
"*"
numb
=
"2"
}
numbSelected
:=
stdinUtils
.
GetInput
(
"(1|2)"
,
numb
,
"enter_language"
,
enCheck
,
zhCheck
)
if
numbSelected
==
"1"
{
language
=
"en"
}
else
{
language
=
"zh"
}
stdinUtils
.
InputForBool
(
&
configSite
,
true
,
"config_zentao_site"
)
if
configSite
{
url
=
stdinUtils
.
GetInput
(
"(http://.*)"
,
conf
.
Url
,
"enter_url"
,
conf
.
Url
)
account
=
stdinUtils
.
GetInput
(
"(.{3,})"
,
conf
.
Account
,
"enter_account"
,
conf
.
Account
)
password
=
stdinUtils
.
GetInput
(
"(.{4,})"
,
conf
.
Password
,
"enter_password"
,
conf
.
Password
)
}
configUtils
.
SaveConfig
(
language
,
url
,
account
,
password
)
configUtils
.
PrintCurrConfig
()
}
func
CheckRequestConfig
()
{
conf
:=
configUtils
.
ReadCurrConfig
()
if
conf
.
Url
==
""
||
conf
.
Account
==
""
||
conf
.
Password
==
""
{
InputForRequest
()
}
}
func
InputForRequest
()
{
conf
:=
configUtils
.
ReadCurrConfig
()
url
:=
""
account
:=
""
password
:=
""
fmt
.
Println
(
i118Utils
.
I118Prt
.
Sprintf
(
"begin_config"
))
url
=
stdinUtils
.
GetInput
(
"(http://.*)"
,
conf
.
Url
,
"enter_url"
,
conf
.
Url
)
account
=
stdinUtils
.
GetInput
(
"(.{3,})"
,
conf
.
Account
,
"enter_account"
,
conf
.
Account
)
password
=
stdinUtils
.
GetInput
(
"(.{4,})"
,
conf
.
Password
,
"enter_password"
,
conf
.
Password
)
configUtils
.
SaveConfig
(
""
,
url
,
account
,
password
)
}
src/atf.go
浏览文件 @
bd4d48f8
...
...
@@ -6,7 +6,6 @@ import (
configUtils
"github.com/easysoft/zentaoatf/src/utils/config"
fileUtils
"github.com/easysoft/zentaoatf/src/utils/file"
logUtils
"github.com/easysoft/zentaoatf/src/utils/log"
stdinUtils
"github.com/easysoft/zentaoatf/src/utils/stdin"
"github.com/easysoft/zentaoatf/src/utils/vari"
"os"
)
...
...
@@ -112,7 +111,7 @@ func main() {
}
case
"set"
,
"-s"
:
stdinUtils
.
InputForSet
()
action
.
InputForSet
()
case
"help"
,
"-h"
:
logUtils
.
PrintUsage
()
...
...
src/utils/stdin/stdin.go
浏览文件 @
bd4d48f8
...
...
@@ -2,7 +2,6 @@ package stdinUtils
import
(
"fmt"
configUtils
"github.com/easysoft/zentaoatf/src/utils/config"
fileUtils
"github.com/easysoft/zentaoatf/src/utils/file"
i118Utils
"github.com/easysoft/zentaoatf/src/utils/i118"
langUtils
"github.com/easysoft/zentaoatf/src/utils/lang"
...
...
@@ -14,113 +13,28 @@ import (
"strings"
)
func
InputForSet
()
{
conf
:=
configUtils
.
ReadCurrConfig
()
var
configSite
bool
language
:=
""
url
:=
""
account
:=
""
password
:=
""
fmt
.
Println
(
i118Utils
.
I118Prt
.
Sprintf
(
"begin_config"
))
enCheck
:=
""
var
numb
string
if
conf
.
Language
==
"en"
{
enCheck
=
"*"
numb
=
"1"
}
zhCheck
:=
""
if
conf
.
Language
==
"zh"
{
zhCheck
=
"*"
numb
=
"2"
}
language
=
getInput
(
"(1|2|)"
,
"enter_language"
,
enCheck
,
zhCheck
)
if
language
==
""
{
language
=
conf
.
Language
logUtils
.
PrintToStdOut
(
numb
,
-
1
)
}
else
if
language
==
"1"
{
language
=
"en"
}
else
{
language
=
"zh"
}
InputForBool
(
&
configSite
,
true
,
"config_zentao_site"
)
if
configSite
{
url
=
getInput
(
"(http://.*|)"
,
"enter_url"
,
conf
.
Url
)
if
url
==
""
{
url
=
conf
.
Url
logUtils
.
PrintToStdOut
(
url
,
-
1
)
}
account
=
getInput
(
"(.{3,}|)"
,
"enter_account"
,
conf
.
Account
)
if
account
==
""
{
account
=
conf
.
Account
logUtils
.
PrintToStdOut
(
account
,
-
1
)
}
password
=
getInput
(
"(.{4,}|)"
,
"enter_password"
,
conf
.
Password
)
if
password
==
""
{
password
=
conf
.
Password
logUtils
.
PrintToStdOut
(
password
,
-
1
)
}
}
configUtils
.
SaveConfig
(
language
,
url
,
account
,
password
)
configUtils
.
PrintCurrConfig
()
}
func
CheckRequestConfig
()
{
conf
:=
configUtils
.
ReadCurrConfig
()
if
conf
.
Url
==
""
||
conf
.
Account
==
""
||
conf
.
Password
==
""
{
InputForRequest
()
}
}
func
InputForRequest
()
{
url
:=
""
account
:=
""
password
:=
""
fmt
.
Println
(
i118Utils
.
I118Prt
.
Sprintf
(
"begin_config"
))
url
=
getInput
(
"http://.*"
,
"enter_url"
)
account
=
getInput
(
".{3,}"
,
"enter_account"
)
password
=
getInput
(
".{4,}"
,
"enter_password"
)
configUtils
.
SaveConfig
(
""
,
url
,
account
,
password
)
configUtils
.
PrintCurrConfig
()
}
func
InputForCheckout
(
productId
*
string
,
moduleId
*
string
,
suiteId
*
string
,
taskId
*
string
,
independentFile
*
bool
,
scriptLang
*
string
)
{
coType
:=
getInput
(
"(1|2|3|4)
"
,
"enter_co_type"
)
coType
:=
GetInput
(
"(1|2|3|4)"
,
"
"
,
"enter_co_type"
)
coType
=
strings
.
ToLower
(
coType
)
if
coType
==
"1"
{
*
productId
=
getInput
(
"
\\
d+
"
,
*
productId
=
GetInput
(
"
\\
d+"
,
"
"
,
i118Utils
.
I118Prt
.
Sprintf
(
"pls_enter"
)
+
" "
+
i118Utils
.
I118Prt
.
Sprintf
(
"product_id"
))
}
else
if
coType
==
"2"
{
*
productId
=
getInput
(
"
\\
d+
"
,
*
productId
=
GetInput
(
"
\\
d+"
,
"
"
,
i118Utils
.
I118Prt
.
Sprintf
(
"pls_enter"
)
+
" "
+
i118Utils
.
I118Prt
.
Sprintf
(
"product_id"
))
*
moduleId
=
getInput
(
"
\\
d+
"
,
*
moduleId
=
GetInput
(
"
\\
d+"
,
"
"
,
i118Utils
.
I118Prt
.
Sprintf
(
"pls_enter"
)
+
" "
+
i118Utils
.
I118Prt
.
Sprintf
(
"module_id"
))
}
else
if
coType
==
"3"
{
*
suiteId
=
getInput
(
"
\\
d+
"
,
*
suiteId
=
GetInput
(
"
\\
d+"
,
"
"
,
i118Utils
.
I118Prt
.
Sprintf
(
"pls_enter"
)
+
" "
+
i118Utils
.
I118Prt
.
Sprintf
(
"suite_id"
))
}
else
if
coType
==
"4"
{
*
taskId
=
getInput
(
"
\\
d+
"
,
*
taskId
=
GetInput
(
"
\\
d+"
,
"
"
,
i118Utils
.
I118Prt
.
Sprintf
(
"pls_enter"
)
+
" "
+
i118Utils
.
I118Prt
.
Sprintf
(
"task_id"
))
}
...
...
@@ -128,7 +42,7 @@ func InputForCheckout(productId *string, moduleId *string, suiteId *string, task
numbs
,
names
,
labels
:=
langUtils
.
GetSupportLanguageOptions
()
fmtParam
:=
strings
.
Join
(
labels
,
"
\n
"
)
numbStr
:=
g
etInput
(
"("
+
strings
.
Join
(
numbs
,
"|"
)
+
")"
,
"enter_co_language"
,
fmtParam
)
numbStr
:=
G
etInput
(
"("
+
strings
.
Join
(
numbs
,
"|"
)
+
")"
,
"enter_co_language"
,
fmtParam
)
numb
,
_
:=
strconv
.
Atoi
(
numbStr
)
...
...
@@ -136,15 +50,11 @@ func InputForCheckout(productId *string, moduleId *string, suiteId *string, task
}
func
InputForDir
(
dir
*
string
,
entity
string
)
{
*
dir
=
getInput
(
"is_dir"
,
"enter_dir"
,
i118Utils
.
I118Prt
.
Sprintf
(
entity
))
}
func
InputForInt
(
in
*
string
,
fmtStr
string
,
fmtParam
...
string
)
{
*
in
=
getInput
(
"
\\
d+"
,
"fmtStr"
,
fmtParam
)
*
dir
=
GetInput
(
"is_dir"
,
""
,
"enter_dir"
,
i118Utils
.
I118Prt
.
Sprintf
(
entity
))
}
func
InputForBool
(
in
*
bool
,
defaultVal
bool
,
fmtStr
string
,
fmtParam
...
string
)
{
str
:=
getInput
(
"(yes|no|y|n|)
"
,
fmtStr
,
fmtParam
)
str
:=
GetInput
(
"(yes|no|y|n|)"
,
"
"
,
fmtStr
,
fmtParam
)
if
str
==
""
{
*
in
=
defaultVal
...
...
@@ -167,7 +77,7 @@ func InputForBool(in *bool, defaultVal bool, fmtStr string, fmtParam ...string)
}
}
func
getInput
(
regx
string
,
fmtStr
string
,
params
...
interface
{})
string
{
func
GetInput
(
regx
string
,
defaultVal
string
,
fmtStr
string
,
params
...
interface
{})
string
{
var
ret
string
msg
:=
i118Utils
.
I118Prt
.
Sprintf
(
fmtStr
,
params
...
)
...
...
@@ -176,6 +86,10 @@ func getInput(regx string, fmtStr string, params ...interface{}) string {
logUtils
.
PrintToStdOut
(
"
\n
"
+
msg
,
color
.
FgCyan
)
fmt
.
Scanln
(
&
ret
)
if
strings
.
TrimSpace
(
ret
)
==
""
{
ret
=
defaultVal
}
temp
:=
strings
.
ToLower
(
ret
)
if
temp
==
"exit"
{
os
.
Exit
(
1
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录