How do you move -h|--help and -v|--version in the help text? #1468
-
By default, Is there any way to move these to the bottom or hide |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
For this you will need to implement a custom help provider: https://spectreconsole.net/cli/command-help |
Beta Was this translation helpful? Give feedback.
-
How did you get on @samuel-lucas6 ? I gave it a go myself, but unfortunately I think it's going to be a rather ugly custom help provider implementation. The example CustomHelpProvider demonstrates overriding one of the write functions, namely:
I thought I could follow suit, overring the appropriate method to simply reorder the options to have The spectre.console HelpProvider renders the options in the following method, which can also be overriden: /// <summary>
/// Gets the options section of the help information.
/// </summary>
public virtual IEnumerable<IRenderable> GetOptions(ICommandModel model, ICommandInfo? command)
{
// Collect all options into a single structure.
var parameters = HelpOption.Get(command, resources); However, public static IReadOnlyList<HelpOption> Get(ICommandInfo? command, HelpProviderResources resources)
{
var parameters = new List<HelpOption>();
parameters.Add(new HelpOption("h", "help", null, null, resources.PrintHelpDescription, null));
// Version information applies to the entire application
// Include the "-v" option in the help when at the root of the command line application
// Don't allow the "-v" option if users have specified one or more sub-commands
if ((command == null || command?.Parent == null) && !(command?.IsBranch ?? false))
{
parameters.Add(new HelpOption("v", "version", null, null, resources.PrintVersionDescription, null));
} I think all of Failing that, I guess two other solutions seem possible, namely:
Truthfully, this behaviour is probably somewhere not very high on the priority list. But equally, I'm open-minded and I'd be interested in hearing your thoughts about the above, and also the importance (or not) of this behaviour for your users. Also comments from any other spectre.console users who may have had similar thoughts. |
Beta Was this translation helpful? Give feedback.
For this you will need to implement a custom help provider: https://spectreconsole.net/cli/command-help