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

list, view scripts using new format

上级 ca4b06ff
...@@ -12,18 +12,17 @@ pid=0 ...@@ -12,18 +12,17 @@ pid=0
3. steps 3. steps
step 3.1.1 step 3.1.1
step 3.1.2 step 3.1.2
[3.1. expects] 3.1. expects
[3.2. steps] 3.2. steps
step 3.2.1 step 3.2.1
step 3.2.2 step 3.2.2
[3.2. expects] 3.2. expects
expect 3.2.1 expect 3.2.1
expect 3.2.2 expect 3.2.2
[group] 4. step 4
4. step 4 5. step 5 >> expect 5
5. step 5 >> expect 5
*/ */
......
...@@ -4,8 +4,10 @@ import ( ...@@ -4,8 +4,10 @@ import (
"fmt" "fmt"
"github.com/easysoft/zentaoatf/src/model" "github.com/easysoft/zentaoatf/src/model"
"github.com/easysoft/zentaoatf/src/utils/common" "github.com/easysoft/zentaoatf/src/utils/common"
constant "github.com/easysoft/zentaoatf/src/utils/const"
"github.com/easysoft/zentaoatf/src/utils/file" "github.com/easysoft/zentaoatf/src/utils/file"
i118Utils "github.com/easysoft/zentaoatf/src/utils/i118" i118Utils "github.com/easysoft/zentaoatf/src/utils/i118"
langUtils "github.com/easysoft/zentaoatf/src/utils/lang"
logUtils "github.com/easysoft/zentaoatf/src/utils/log" logUtils "github.com/easysoft/zentaoatf/src/utils/log"
zentaoUtils "github.com/easysoft/zentaoatf/src/utils/zentao" zentaoUtils "github.com/easysoft/zentaoatf/src/utils/zentao"
"github.com/fatih/color" "github.com/fatih/color"
...@@ -120,14 +122,26 @@ func View(cases []string, keywords string) { ...@@ -120,14 +122,26 @@ func View(cases []string, keywords string) {
func Brief(file string, keywords string) (bool, []string) { func Brief(file string, keywords string) (bool, []string) {
content := fileUtils.ReadFile(file) content := fileUtils.ReadFile(file)
lang := langUtils.GetLangByFile(file)
isOldFormat := strings.Index(content, "[esac]") > -1
myExp := regexp.MustCompile( regStr := ""
`\[case\][\S\s]*` + if isOldFormat {
regStr = `\[case\][\S\s]*` +
`title=([^\n]*)\n+` + `title=([^\n]*)\n+` +
`cid=([^\n]*)\n+` + `cid=([^\n]*)\n+` +
`pid=([^\n]*)\n+` + `pid=([^\n]*)\n+` +
`([\S\s]*)\n*` + `([\S\s]*)\n*` +
`\[esac\]`) `\[esac\]`
} else {
regStr = fmt.Sprintf(`(?sm)%s[\S\s]*`+
`title=([^\n]*)\n+`+
`cid=([^\n]*)\n+`+
`pid=([^\n]*)\n+`+
`([\S\s]*)\n*%s`,
constant.LangCommentsMap[lang][0], constant.LangCommentsMap[lang][1])
}
myExp := regexp.MustCompile(regStr)
arr := myExp.FindStringSubmatch(content) arr := myExp.FindStringSubmatch(content)
if len(arr) > 2 { if len(arr) > 2 {
......
...@@ -83,7 +83,7 @@ func GetCaseInfo(file string) (bool, int, int, string) { ...@@ -83,7 +83,7 @@ func GetCaseInfo(file string) (bool, int, int, string) {
if isOldFormat { if isOldFormat {
regStr = `(?s)\[case\](.*)\[esac\]` regStr = `(?s)\[case\](.*)\[esac\]`
} else { } else {
regStr = fmt.Sprintf(`(?Us)%s(.*)%s`, regStr = fmt.Sprintf(`(?sm)%s((?U:.*pid.*))\n(.*)%s`,
constant.LangCommentsMap[lang][0], constant.LangCommentsMap[lang][1]) constant.LangCommentsMap[lang][0], constant.LangCommentsMap[lang][1])
} }
myExp := regexp.MustCompile(regStr) myExp := regexp.MustCompile(regStr)
......
...@@ -140,11 +140,11 @@ func main() { ...@@ -140,11 +140,11 @@ func main() {
case "set", "-set": case "set", "-set":
action.Set() action.Set()
case "sort", "-sort": //case "sort", "-sort":
files := fileUtils.GetFilesFromParams(os.Args[2:]) // files := fileUtils.GetFilesFromParams(os.Args[2:])
if err := flagSet.Parse(os.Args[len(files)+2:]); err == nil { // if err := flagSet.Parse(os.Args[len(files)+2:]); err == nil {
action.Sort(files) // action.Sort(files)
} // }
case "clean", "-clean", "-c": case "clean", "-clean", "-c":
action.Clean() action.Clean()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册