-
Notifications
You must be signed in to change notification settings - Fork 120
Description
If I have no "root" command per se, and want to take advantage of the generated Commands: list and the usage instructions for help text, but also want to provide a description between the usage and commands list for the (generated) root command's help text, I don't seem to have a way of doing that.
I've tried adding doc comments to a [Command("")]-attributed method registered with Add<T>(), but that (as you would expect) simply makes the default help text output go away, instead executing whatever logic is implemented in that method - which would work if I had a way of explicitly calling the built-in usage/help information from ConsoleAppContext (or at least, getting the string and manipulating myself), but it's all locked away because the generated ConsoleApp.ConsoleAppBuilder.ShowHelp(int helpId) method is private.
Example:
using ConsoleAppFramework;
var app = ConsoleApp.Create();
app.Add<Commands>();
app.Run(args);
internal class Commands
{
/// <summary>
/// Displays customized messages for different scenarios.
/// </summary>
/// <param name="context">The app context.</param>
[Command("")]
public void Run(ConsoleAppContext context)
{
// Problem: What can I do here to inject "Displays customized messages for different scenarios."?
}
/// <summary>
/// Displays a greeting message.
/// </summary>
/// <param name="message">-m, The message to show.</param>
public void Greet(string message) => Console.WriteLine($"Hello, {message}");
/// <summary>
/// Displays a farewell message.
/// </summary>
/// <param name="message">-m, The message to show.</param>
public void Bye(string message) => Console.WriteLine($"Goodbye, {message}");
}
Expected output of -h argument list:
Usage: [options...] [-h|--help] [--version]
Displays customized messages for different scenarios.
Commands:
greet Displays a greeting message.
bye Displays a farewell message.
Perhaps just allow people to make the command method with [Command("")] to optionally be made partial, and if it is, then it continues to produce the default behavior but also takes into account your XML doc comments?