command-line-api icon indicating copy to clipboard operation
command-line-api copied to clipboard

Is there a automatic included "--help" command to print all subcommands ?

Open genaray opened this issue 3 years ago • 4 comments

I want to print all my subcommands or all commands in total, like a typical "--help" command does in most apps. I actually need this as a string, so i can send it to my client which actually inputs the commands.

Is something like this already included ? Or do i need to craft this by myself, if so... how ? Glad for any help due to the lack of documentation and the beta guide couldnt help me either.

genaray avatar Apr 12 '22 17:04 genaray

If you run your command via the 'default' CommandLineBuilder, one of the middleware provided handles help in the way you're describing. There's a worked example here if that helps illustrate the usage?

baronfel avatar Apr 12 '22 17:04 baronfel

If you want to get the help output as a string, you can use the HelpBuilder directly: image

jonsequitur avatar Apr 12 '22 20:04 jonsequitur

If you want to get the help output as a string, you can use the HelpBuilder directly: image

Thanks a lot ! This already helped :) One little problem left, my root command has several subcommands registered. Those subcommands have options and stuff. When i use the HelpBuilder to generate that describtion, it mentions my subcommands... but not the options of my subcommands. However i added an describtion for them.

Is there a way to use the help builder to generate a whole describtion for the whole command tree ?

genaray avatar Apr 15 '22 15:04 genaray

Not currently, but take a look at custom help layouts. These APIs are intended to enable this kind of customization.

https://docs.microsoft.com/en-us/dotnet/standard/commandline/customize-help

jonsequitur avatar Apr 15 '22 17:04 jonsequitur