spf13 / cobra

A Commander for modern Go CLI interactions
https://cobra.dev
Apache License 2.0
37.87k stars 2.84k forks source link

Parameterised subcommand #1378

Closed paulhobbel closed 3 years ago

paulhobbel commented 3 years ago

Is it possible to have parameterised subcommands, I don't know the proper naming, but I have an example below

vumm mod <modname> grant <user> <permission>

I've searched the documentation and also previous issues, but failed to find anything

marckhouzam commented 3 years ago

I don't believe this is possible @paulhobbel. You could rearrange the arguments or use a flag: vumm mod grant <modname> <user> <permission> or vumm mod grant <user> <permission> <modname> or vumm mod --modname <modname> grant <user> <permission>

But if we take a step back it seems like the main command in this example in the grant command and not the mod command. So maybe it would be better to do something like: vumm grant --mod <modname> <user> <permission> or vumm grant <modname> <user> <permission>

paulhobbel commented 3 years ago

Solved by switching it to just grant yea, the idea was to have multiple subcommands for "mods"

marckhouzam commented 3 years ago

Great, so if everything is working for you, could you close this issue @paulhobbel, I don't have permissions. Thanks.

paulhobbel commented 3 years ago

Will do, thanks for the help anyhow