mirror of
https://github.com/Tyrrrz/CliFx.git
synced 2025-10-25 15:19:17 +00:00
Inform user that they can use help on a specific command
This commit is contained in:
@@ -124,17 +124,25 @@ namespace CliFx.Services
|
||||
buffer.AppendLine();
|
||||
}
|
||||
|
||||
public string Build(IReadOnlyList<CommandSchema> commandSchemas, CommandSchema commandSchema)
|
||||
public string Build(IReadOnlyList<CommandSchema> availableCommandSchemas, CommandSchema matchingCommandSchema)
|
||||
{
|
||||
var buffer = new StringBuilder();
|
||||
|
||||
var subCommands = commandSchemas.FindSubCommandSchemas(commandSchema.Name);
|
||||
var subCommands = availableCommandSchemas.FindSubCommandSchemas(matchingCommandSchema.Name);
|
||||
|
||||
AddDescription(buffer, commandSchema);
|
||||
AddUsage(buffer, commandSchema, subCommands);
|
||||
AddOptions(buffer, commandSchema);
|
||||
AddDescription(buffer, matchingCommandSchema);
|
||||
AddUsage(buffer, matchingCommandSchema, subCommands);
|
||||
AddOptions(buffer, matchingCommandSchema);
|
||||
AddSubCommands(buffer, subCommands);
|
||||
|
||||
if (matchingCommandSchema.IsDefault() && subCommands.Any())
|
||||
{
|
||||
buffer.Append("You can run ");
|
||||
buffer.Append('`').Append(GetExeName()).Append(" [command] --help").Append('`');
|
||||
buffer.Append(" to show information for a specific command.");
|
||||
buffer.AppendLine();
|
||||
}
|
||||
|
||||
return buffer.ToString().Trim();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,6 @@ namespace CliFx.Services
|
||||
{
|
||||
public interface ICommandHelpTextBuilder
|
||||
{
|
||||
string Build(IReadOnlyList<CommandSchema> commandSchemas, CommandSchema commandSchema);
|
||||
string Build(IReadOnlyList<CommandSchema> availableCommandSchemas, CommandSchema matchingCommandSchema);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user