I am trying to figure out how to categorize commands in Click to resemble something close to the structure that kubectl
uses in the way it separate commands out.
For instance, in a vanilla Click help output we have:
Usage: cli.py [OPTIONS] COMMAND [ARGS]...
A CLI tool
Options:
-h, --help Show this message and exit.
Commands:
command1 This is command1
command2 This is command2
command3 This is command3
command4 This is command4
Instead, what would be ideal for my usage is to have a separation to better categorize the command structure.
For instance:
Usage: cli.py [OPTIONS] COMMAND [ARGS]...
A CLI tool
Options:
-h, --help Show this message and exit.
Specific Commands for X:
command1 This is command1
command2 This is command2
Specific Commands for Y:
command3 This is command3
command4 This is command4
Global Commands:
version Shows version
I am using the latest Python and latest version of Click also for this.
I have tried looking into hooking into various Click classes to change this behaviour but have been unsuccessful in doing so. Closest I have gotten is being able to structure commands based on priority but I am not able to logically separate them out as in the example above.
Any help would be greatly appreciated.
self.commands
part but I will see what suggestion you come back with. – Oceanid