Added command description to command help message (#920)

This commit is contained in:
nkochnev 2022-08-17 19:59:08 +05:00 committed by GitHub
parent d94dc2fcb2
commit 78d841e3dc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 29 additions and 0 deletions

View File

@ -75,6 +75,7 @@ internal static class HelpWriter
var isDefaultCommand = command?.IsDefaultCommand ?? false;
var result = new List<IRenderable>();
result.AddRange(GetDescription(command));
result.AddRange(GetUsage(model, command));
result.AddRange(GetExamples(model, command));
result.AddRange(GetArguments(command));
@ -84,6 +85,19 @@ internal static class HelpWriter
return result;
}
private static IEnumerable<IRenderable> GetDescription(CommandInfo? command)
{
if (command?.Description == null)
{
yield break;
}
var composer = new Composer();
composer.Style("yellow", "DESCRIPTION:").LineBreak();
composer.Text(command.Description).LineBreak();
yield return composer.LineBreak();
}
private static IEnumerable<IRenderable> GetUsage(CommandModel model, CommandInfo? command)
{
var composer = new Composer();

View File

@ -1,3 +1,6 @@
DESCRIPTION:
Contains settings for a cat.
USAGE:
myapp cat [LEGS] [OPTIONS] <COMMAND>

View File

@ -1,3 +1,6 @@
DESCRIPTION:
The animal command.
USAGE:
myapp animal [LEGS] [OPTIONS] <COMMAND>

View File

@ -1,3 +1,6 @@
DESCRIPTION:
The lion command.
USAGE:
myapp <TEETH> [LEGS] [OPTIONS]

View File

@ -1,3 +1,6 @@
DESCRIPTION:
The lion command.
USAGE:
myapp <TEETH> [LEGS] [OPTIONS]

View File

@ -1,3 +1,6 @@
DESCRIPTION:
The lion command.
USAGE:
myapp cat [LEGS] lion <TEETH> [OPTIONS]