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

code refactoring for exe logic

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