Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is it possible to list all commands, subcommands and all options in one go? #2297

Open
Cowraider opened this issue Dec 19, 2024 · 2 comments

Comments

@Cowraider
Copy link

Cowraider commented Dec 19, 2024

Currently, when creating a somewhat complex command structure, I need to work with "--help" to find out which subcommands/options a command supports (or look at the code obviously).

I would like to have some kind of autocomplete that makes sure I can only enter "valid" subcommands in a chainable way.
So for instance I have commandA that has commandB, where commandB has an option "-input" of type string.
Now it would be nice to use a command chaining generator like this: commandGenerator.commandA(),commandB().optionInput('someString'). which would then generate commandA commandB --input 'someString'.

To do that I would extract all possible commands, subcommands, options etc. and generate a commandChainer class. Unfortunately I haven't found a way of listing all commands in one go, I can only show the help for each command separately.

Is there any way I can do something like this?

@shadowspawn
Copy link
Collaborator

Given the root Command object for your command structure, there are properties for the subcommands and options and arguments. This would be much simpler to work with than parsing the Help output.

Some related issues: #1653 #1823 #1875

@Cowraider
Copy link
Author

Amazing, thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants