diff options
author | Sebastien Douheret <sebastien.douheret@iot.bzh> | 2017-12-05 14:56:14 +0100 |
---|---|---|
committer | Sebastien Douheret <sebastien.douheret@iot.bzh> | 2017-12-05 14:56:14 +0100 |
commit | 407b8190b86e31f5e1fbd31fae30dcbf8be36fe6 (patch) | |
tree | 7226278572532e865d0df30394116869f5543369 /main.go | |
parent | 2e1b9ab05d094f03f8dc2904bac02ab9904a4824 (diff) |
Support --config option either before or after command verb.
Diffstat (limited to 'main.go')
-rw-r--r-- | main.go | 13 |
1 files changed, 13 insertions, 0 deletions
@@ -189,6 +189,19 @@ func main() { initCmdExec(&app.Commands) initCmdMisc(&app.Commands) + // Add --config option to all commands to support --config option either before or after command verb + // IOW support following both syntaxes: + // xds-cli exec --config myprj.conf ... + // xds-cli --config myprj.conf exec ... + for i, cmd := range app.Commands { + if len(cmd.Flags) > 0 { + app.Commands[i].Flags = append(cmd.Flags, cli.StringFlag{Hidden: true, Name: "config, c"}) + } + for j, subCmd := range cmd.Subcommands { + app.Commands[i].Subcommands[j].Flags = append(subCmd.Flags, cli.StringFlag{Hidden: true, Name: "config, c"}) + } + } + sort.Sort(cli.FlagsByName(app.Flags)) sort.Sort(cli.CommandsByName(app.Commands)) |