gcli
gcli copied to clipboard
when setting default command to gcli app, ./appcli can't run with default command
System (please complete the following information):
- OS:
windows 10 - GO Version:
1.21.6 - Pkg Version:
v3.2.3
Describe the bug
I set a ‘run’ command for the app through ‘app.SetDefaultCommand’, and want the app to execute the ‘run’ command by default (./app). But after compiling, I run ‘./app’ and get an error ‘ERROR: unknown input command "run"’
To Reproduce
package main
import (
"fmt"
"github.com/gookit/gcli/v3"
"log"
)
var run = &gcli.Command{
Name: "run",
Desc: "run app client",
Func: func(c *gcli.Command, args []string) error {
//server.Run()
fmt.Println("test default command")
return nil
},
//Hidden: true,
}
func Run() {
app := gcli.NewApp()
app.Version = "1.0.0"
app.Name = "Test Client"
app.Desc = ""
app.Add(run)
app.SetDefaultCommand(run.Name)
app.Run(nil)
}
func main() {
Run()
}
Expected behavior
I expected to happen: execute "./app" command, then the app will execute 'run' command,just like execute "./app run"