-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Description
The default help message for subcommands that don't have further subcommands seems cluttered with extra [command [command options]]
part.
Example
Got:
NAME:
app hello - Prints hello message.
USAGE:
app hello [command [command options]] name
OPTIONS:
--lang string
--help, -h show help
GLOBAL OPTIONS:
--global-flag string
Want:
NAME:
app hello - Prints hello message.
USAGE:
app hello [options] name
OPTIONS:
--lang string
--help, -h show help
GLOBAL OPTIONS:
--global-flag string
Reproduction code:
package main
import (
"bytes"
"context"
"fmt"
"github.com/urfave/cli/v3"
)
func main() {
var b bytes.Buffer
app := &cli.Command{
Name: "app",
Usage: "Sample app to reproduce a cluttered subcommand help.",
Action: func(ctx context.Context, cmd *cli.Command) error {
fmt.Println("root command")
return nil
},
Flags: []cli.Flag{
&cli.StringFlag{
Name: "global-flag",
},
},
Commands: []*cli.Command{
{
Name: "hello",
Usage: "Prints hello message.",
Action: func(ctx context.Context, cmd *cli.Command) error {
fmt.Println("Hello", cmd.StringArg("name"))
return nil
},
Arguments: []cli.Argument{
&cli.StringArg{
Name: "name",
},
},
Flags: []cli.Flag{
&cli.StringFlag{
Name: "lang",
},
},
},
},
Writer: &b,
}
if err := app.Run(context.Background(), []string{"app", "hello", "--help"}); err != nil {
panic(err)
}
fmt.Println(b.String())
}
Metadata
Metadata
Assignees
Labels
No labels