add run command for test

This commit is contained in:
tickstep 2023-04-01 20:20:32 +08:00
parent e33d23831a
commit 50a05a6bec

24
main.go
View File

@ -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",