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

set script language interpreter

上级 04fb441e
package main
import (
"fmt"
"regexp"
commonUtils "github.com/easysoft/zentaoatf/src/utils/common"
configUtils "github.com/easysoft/zentaoatf/src/utils/config"
)
var content = `[4. steps]
step4...
line1...
line2...
[4. expects]
[5. steps]
step5...
[5. expects]
[6. steps]
step6...
[6. expects]
?>`
func main() {
myExp := regexp.MustCompile(`(?U)\[.*steps\]([\S\s]+)\[(.*steps.*|$)\]`)
config := configUtils.ReadCurrConfig()
arr := myExp.FindAllStringSubmatch(content, -1)
fmt.Printf("%+v", arr)
commonUtils.SetFieldVal(config, "php", "sdfdsf")
}
......@@ -7,6 +7,7 @@ import (
constant "github.com/easysoft/zentaoatf/src/utils/const"
"github.com/easysoft/zentaoatf/src/utils/file"
langUtils "github.com/easysoft/zentaoatf/src/utils/lang"
stringUtils "github.com/easysoft/zentaoatf/src/utils/string"
zentaoUtils "github.com/easysoft/zentaoatf/src/utils/zentao"
"io/ioutil"
"os"
......@@ -164,9 +165,10 @@ func GetScriptType(scripts []string) []string {
ext := path.Ext(script)
if ext != "" {
ext = ext[1:]
if !stringUtils.FindInArr(ext, exts) {
exts = append(exts, extMap[ext])
}
}
exts = append(exts, extMap[ext])
}
return exts
......
......@@ -90,10 +90,10 @@ func GetFieldVal(config model.Config, key string) string {
return val
}
func SetFieldVal(config model.Config, key string, val string) string {
func SetFieldVal(config *model.Config, key string, val string) string {
key = stringUtils.Ucfirst(key)
mutable := reflect.ValueOf(&config).Elem()
mutable := reflect.ValueOf(config).Elem()
mutable.FieldByName(key).SetString(val)
return val
......
......@@ -38,6 +38,8 @@ func InitScreenSize() {
}
func SaveConfig(conf model.Config) error {
fmt.Printf("\n%s=%s\n", "php", conf.Php)
fileUtils.MkDirIfNeeded(fileUtils.GetZtfDir() + "conf")
conf.Version = constant.ConfigVer
......@@ -152,6 +154,8 @@ func InputForSet() {
scripts := assertUtils.GetCaseByDirAndFile([]string{"."})
InputForScriptInterpreter(scripts, &conf)
fmt.Printf("\n%s=%s\n", "php", conf.Php)
SaveConfig(conf)
PrintCurrConfig()
}
......@@ -183,7 +187,13 @@ func InputForScriptInterpreter(scripts []string, config *model.Config) {
for _, lang := range langs {
inter := stdinUtils.GetInput(".*", commonUtils.GetFieldVal(*config, lang), "set_script_interpreter", lang)
commonUtils.SetFieldVal(*config, lang, inter)
fmt.Printf("lang: %s, inter: %s", lang, inter)
commonUtils.SetFieldVal(config, lang, inter)
}
fmt.Printf("\n%s=%s\n", "php", (*config).Php)
//}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册