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

code refactoring for exe logic

上级 7aacfb04
......@@ -23,13 +23,13 @@ func Run(files []string, suiteIdStr string, taskIdStr string) error {
cases := make([]string, 0)
if suiteIdStr != "" {
if len(files) == 0 { // run with suite/task id, but no dir
if suiteIdStr != "" { // run with suite id,
if len(files) == 0 { // no dir
files[0] = fileUtils.AbosutePath(".")
}
cases = getCaseBySuiteId(suiteIdStr, files[0])
} else if taskIdStr != "" {
if len(files) == 0 { // run with suite/task id, but no dir
} else if taskIdStr != "" { // run with task id,
if len(files) == 0 { // no dir
files[0] = fileUtils.AbosutePath(".")
}
cases = getCaseByTaskId(taskIdStr, files[0])
......
......@@ -118,9 +118,8 @@ func main() {
args = append(args, "run")
args = append(args, os.Args[1:]...)
os.Args = args
files := fileUtils.GetFilesFromParams(os.Args[2:])
if err := flagSet.Parse(os.Args[len(files)+2:]); err == nil {
files := fileUtils.GetFilesFromParams(args[2:])
if err := flagSet.Parse(args[len(files)+2:]); err == nil {
action.Run(files, suiteId, taskId)
}
} else {
......
......@@ -68,18 +68,20 @@ func AbosutePath(pth string) string {
pth, _ = filepath.Abs(pth)
}
pth = UpdateDir(pth)
if IsDir(pth) {
pth = UpdateDir(pth)
}
return pth
}
func UpdateDir(path string) string {
func UpdateDir(pth string) string {
sepa := string(os.PathSeparator)
if strings.LastIndex(path, sepa) < len(path)-1 {
path += sepa
if strings.LastIndex(pth, sepa) < len(pth)-1 {
pth += sepa
}
return path
return pth
}
func GetFilesFromParams(arguments []string) []string {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册