|
|
@ -51,14 +51,15 @@ func Run(cmd *cobra.Command, args []string) { |
|
|
|
cmdPaths = append(cmdPaths, k) |
|
|
|
cmdPaths = append(cmdPaths, k) |
|
|
|
} |
|
|
|
} |
|
|
|
prompt := &survey.Select{ |
|
|
|
prompt := &survey.Select{ |
|
|
|
Message: "Which directory do you want to run?", |
|
|
|
Message: "Which directory do you want to run?", |
|
|
|
Options: cmdPaths, |
|
|
|
Options: cmdPaths, |
|
|
|
|
|
|
|
PageSize: 10, |
|
|
|
} |
|
|
|
} |
|
|
|
e := survey.AskOne(prompt, &dir) |
|
|
|
e := survey.AskOne(prompt, &dir) |
|
|
|
if e != nil || dir == "" { |
|
|
|
if e != nil || dir == "" { |
|
|
|
return |
|
|
|
return |
|
|
|
} |
|
|
|
} |
|
|
|
dir = path.Join(cmdPath[dir], dir) |
|
|
|
dir = cmdPath[dir] |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
fd := exec.Command("go", "run", ".") |
|
|
|
fd := exec.Command("go", "run", ".") |
|
|
@ -72,6 +73,13 @@ func Run(cmd *cobra.Command, args []string) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func findCMD(base string) (map[string]string, error) { |
|
|
|
func findCMD(base string) (map[string]string, error) { |
|
|
|
|
|
|
|
wd, err := os.Getwd() |
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
|
|
|
return nil, err |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if !strings.HasSuffix(wd, "/") { |
|
|
|
|
|
|
|
wd += "/" |
|
|
|
|
|
|
|
} |
|
|
|
var root bool |
|
|
|
var root bool |
|
|
|
next := func(dir string) (map[string]string, error) { |
|
|
|
next := func(dir string) (map[string]string, error) { |
|
|
|
cmdPath := make(map[string]string) |
|
|
|
cmdPath := make(map[string]string) |
|
|
@ -84,7 +92,8 @@ func findCMD(base string) (map[string]string, error) { |
|
|
|
} |
|
|
|
} |
|
|
|
for _, fileInfo := range paths { |
|
|
|
for _, fileInfo := range paths { |
|
|
|
if fileInfo.IsDir() { |
|
|
|
if fileInfo.IsDir() { |
|
|
|
cmdPath[path.Join("cmd", fileInfo.Name())] = filepath.Join(walkPath, "..") |
|
|
|
abs := path.Join(walkPath, fileInfo.Name()) |
|
|
|
|
|
|
|
cmdPath[strings.TrimPrefix(abs, wd)] = abs |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return nil |
|
|
|
return nil |
|
|
|