-
-
Notifications
You must be signed in to change notification settings - Fork 112
Open
Description
Hi!
Is there a way to make short flags local to subcommands?
For example i would like to make such flags:
type TrackMode struct {
Project string `arg:"-p,--project" help:"project ID"`
Issue string `arg:"-i,--issue" help:"issue ID"`
Comment string `arg:"-c,--comment" help:"comment"`
Hours float32 `arg:"-h,--hours" help:"hours"`
}
type CalendarMode struct {
Month int `arg:"-m,--month" help:"choose month (default: current month)"`
Year int `arg:"-y,--year" help:"choose year (default: current year)"`
}
type Args struct {
Calendar *CalendarMode `arg:"subcommand:cal" help:"calendar"`
Track *TrackMode `arg:"subcommand:track" help:"track time"`
Debug bool `arg:"-d,--debug" help:"enable debug"`
Config string `arg:"-c,--" placeholder:"CONFIG" help:"config path (default: ~/.config/workdiary/config.json)"`
PrintConfigExample bool `arg:"-p,--print-conf-example" help:"print example of config and exit"`
}as you see, it is convenient to have short flags like -p, -i, -c and -h for subcommand track
but they conflict with the global ones:
.... ......
Config string `arg:"-c,--" placeholder:"CONFIG" help:"config path (default: ~/.config/workdiary/config.json)"`
PrintConfigExample bool `arg:"-p,--print-conf-example" help:"print example of config and exit"`
$ cmd track -p 1234 prints the default config,
$ cmd track -h 1 conflict with the default global help: -h,--help,
$ cmd track -c comment parsed as custom config path, what obviously is not what is wanted...
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels