Inform user that they can use help on a specific command

This commit is contained in:
Alexey Golub
2019-07-25 23:12:58 +03:00
parent dd2789790e
commit 24eef8957d
2 changed files with 14 additions and 6 deletions

View File

@@ -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();
}
}

View File

@@ -5,6 +5,6 @@ namespace CliFx.Services
{
public interface ICommandHelpTextBuilder
{
string Build(IReadOnlyList<CommandSchema> commandSchemas, CommandSchema commandSchema);
string Build(IReadOnlyList<CommandSchema> availableCommandSchemas, CommandSchema matchingCommandSchema);
}
}