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

list, view scripts using new format

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