mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-04-16 00:42:51 +08:00
Added command description to command help message (#920)
This commit is contained in:
parent
d94dc2fcb2
commit
78d841e3dc
@ -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();
|
||||
|
@ -1,3 +1,6 @@
|
||||
DESCRIPTION:
|
||||
Contains settings for a cat.
|
||||
|
||||
USAGE:
|
||||
myapp cat [LEGS] [OPTIONS] <COMMAND>
|
||||
|
||||
|
@ -1,3 +1,6 @@
|
||||
DESCRIPTION:
|
||||
The animal command.
|
||||
|
||||
USAGE:
|
||||
myapp animal [LEGS] [OPTIONS] <COMMAND>
|
||||
|
||||
|
@ -1,3 +1,6 @@
|
||||
DESCRIPTION:
|
||||
The lion command.
|
||||
|
||||
USAGE:
|
||||
myapp <TEETH> [LEGS] [OPTIONS]
|
||||
|
||||
|
@ -1,3 +1,6 @@
|
||||
DESCRIPTION:
|
||||
The lion command.
|
||||
|
||||
USAGE:
|
||||
myapp <TEETH> [LEGS] [OPTIONS]
|
||||
|
||||
|
@ -1,3 +1,6 @@
|
||||
DESCRIPTION:
|
||||
The lion command.
|
||||
|
||||
USAGE:
|
||||
myapp cat [LEGS] lion <TEETH> [OPTIONS]
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user