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

code refactoring for exe logic

上级 f491a807
......@@ -21,6 +21,16 @@
"message": "result",
"translation": "result"
},
{
"id": "want_to_continue",
"message": "",
"translation": "Do you want to continue[Y/n]?"
},
{
"id": "case_update_confirm",
"message": "",
"translation": "Will update case as below:\n Title: %s"
},
{
"id": "enter_dir",
"message": "enter dir",
......
......@@ -21,6 +21,16 @@
"message": "result",
"translation": "结果"
},
{
"id": "want_to_continue",
"message": "",
"translation": "确认继续[Y/n]?"
},
{
"id": "case_update_confirm",
"message": "",
"translation": "以下用例信息将被更新:\n 标题: %s"
},
{
"id": "enter_dir",
"message": "enter dir",
......
......@@ -25,8 +25,10 @@ func Login(baseUrl string, account string, password string) bool {
var log string
_, ok = client.PostStr(url, params)
if ok {
log = i118Utils.I118Prt.Sprintf("success_to_login")
logUtils.PrintToCmd(log, -1)
if vari.Verbose {
log = i118Utils.I118Prt.Sprintf("success_to_login")
logUtils.PrintToCmd(log, -1)
}
} else {
log = i118Utils.I118Prt.Sprintf("fail_to_login")
logUtils.PrintToCmd(log, color.FgRed)
......
......@@ -8,6 +8,7 @@ import (
configUtils "github.com/easysoft/zentaoatf/src/utils/config"
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/zentao"
"sort"
"strconv"
......@@ -217,10 +218,16 @@ func CommitCase(caseId int, title string) {
uri := fmt.Sprintf("testcase-edit-%d.json", caseId)
requestObj := map[string]interface{}{"title": title}
url := config.Url + uri
_, ok = client.PostObject(url, requestObj)
var yes bool
logUtils.PrintToStdOut("\n"+i118Utils.I118Prt.Sprintf("case_update_confirm", title), -1)
stdinUtils.InputForBool(&yes, "want_to_continue")
if ok {
logUtils.PrintToStdOut(i118Utils.I118Prt.Sprintf("success_to_commit_case", caseId)+"\n", -1)
if yes {
url := config.Url + uri
_, ok = client.PostObject(url, requestObj)
if ok {
logUtils.PrintToStdOut(i118Utils.I118Prt.Sprintf("success_to_commit_case", caseId)+"\n", -1)
}
}
}
......@@ -117,6 +117,16 @@ func InputForInt(in *string, entity string) {
*in = getInput("\\d+", "enter_id", i118Utils.I118Prt.Sprintf(entity))
}
func InputForBool(in *bool, entity string) {
str := getInput("(yes|no|y|n)", i118Utils.I118Prt.Sprintf(entity), "")
if str != "n" && str != "no" {
*in = true
} else {
*in = false
}
}
func getInput(regx string, fmtStr string, params ...interface{}) string {
var ret string
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册