From 50a05a6bec5602072caa9e08a50f25bc2e54c3b6 Mon Sep 17 00:00:00 2001 From: tickstep Date: Sat, 1 Apr 2023 20:20:32 +0800 Subject: [PATCH] add run command for test --- main.go | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/main.go b/main.go index 013b59c..99e9b95 100644 --- a/main.go +++ b/main.go @@ -20,6 +20,7 @@ import ( "github.com/tickstep/aliyunpan/cmder/cmdtable" "io/ioutil" "os" + "os/exec" "path" "path/filepath" "runtime" @@ -600,6 +601,29 @@ func main() { HideHelp: true, }, + // 执行系统命令 + { + Name: "run", + Usage: "执行系统命令", + Category: "其他", + Action: func(c *cli.Context) error { + if c.NArg() == 0 { + cli.ShowCommandHelp(c, c.Command.Name) + return nil + } + + cmd := exec.Command(c.Args().First(), c.Args().Tail()...) + cmd.Stdout = os.Stdout + cmd.Stdin = os.Stdin + cmd.Stderr = os.Stderr + err := cmd.Run() + if err != nil { + fmt.Println(err) + } + return nil + }, + }, + // 调试用 debug //{ // Name: "debug",