subcommand help did show global options.
yorkz1994 opened this issue · comments
My urfave/cli version is
V2.27.1
Checklist
Dependency Management
Describe the bug
Help for subcommand does not show global options, this can lead to confusion if global flag is required because when call subcommand, it always show help of subcommand instead of running it. And you will never know why it does not run subcommand and always show subcommand help.
To reproduce
package main
import (
"fmt"
"os"
"github.com/urfave/cli/v2"
)
func main() {
app := &cli.App{
Flags: []cli.Flag{
&cli.StringFlag{
Name: "s",
Required: true,
},
},
Commands: []*cli.Command{
{
Name: "add",
Usage: "add a task to the list",
Flags: []cli.Flag{
&cli.IntFlag{
Name: "i",
},
},
Action: func(cCtx *cli.Context) error {
fmt.Println("add")
return nil
},
},
},
}
app.Run(os.Args)
}
Observed behavior
go run main.go add
NAME:
main.exe add - add a task to the list
USAGE:
main.exe add [command options] [arguments...]
OPTIONS:
-i value (default: 0)
--help, -h show help
If run subcommand, it will show help of add
instead of running it. Because no global option in the subcommand help output, you never know that is caused by missing a required global option "s". If I set global option to not required, then subcommand add
will be executed.
Expected behavior
When run help subcommand, it should show global options.
@yorkz1994 This is a duplicate of #734 . We dont have support for this in v2. If you want to push a PR onto v3 with this support I will be glad to review.