|
|
@ -23,8 +23,9 @@ var CmdRun = &cobra.Command{ |
|
|
|
// Run run project.
|
|
|
|
// Run run project.
|
|
|
|
func Run(cmd *cobra.Command, args []string) { |
|
|
|
func Run(cmd *cobra.Command, args []string) { |
|
|
|
var dir string |
|
|
|
var dir string |
|
|
|
if len(args) > 0 { |
|
|
|
cmdArgs, programArgs := splitArgs(cmd, args) |
|
|
|
dir = args[0] |
|
|
|
if len(cmdArgs) > 0 { |
|
|
|
|
|
|
|
dir = cmdArgs[0] |
|
|
|
} |
|
|
|
} |
|
|
|
base, err := os.Getwd() |
|
|
|
base, err := os.Getwd() |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
@ -63,7 +64,7 @@ func Run(cmd *cobra.Command, args []string) { |
|
|
|
dir = cmdPath[dir] |
|
|
|
dir = cmdPath[dir] |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
fd := exec.Command("go", "run", ".") |
|
|
|
fd := exec.Command("go", append([]string{"run", "."}, programArgs...)...) |
|
|
|
fd.Stdout = os.Stdout |
|
|
|
fd.Stdout = os.Stdout |
|
|
|
fd.Stderr = os.Stderr |
|
|
|
fd.Stderr = os.Stderr |
|
|
|
fd.Dir = dir |
|
|
|
fd.Dir = dir |
|
|
@ -73,6 +74,14 @@ func Run(cmd *cobra.Command, args []string) { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func splitArgs(cmd *cobra.Command, args []string) (cmdArgs, programArgs []string) { |
|
|
|
|
|
|
|
dashAt := cmd.ArgsLenAtDash() |
|
|
|
|
|
|
|
if dashAt >= 0 { |
|
|
|
|
|
|
|
return args[:dashAt], args[dashAt:] |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return args, []string{} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
func findCMD(base string) (map[string]string, error) { |
|
|
|
func findCMD(base string) (map[string]string, error) { |
|
|
|
wd, err := os.Getwd() |
|
|
|
wd, err := os.Getwd() |
|
|
|
if err != nil { |
|
|
|
if err != nil { |
|
|
|