Merge pull request #5922 from rtpHarry/orchardexe-help-filter

Make orchard help command more intuitive

Closes #422
This commit is contained in:
Sébastien Ros
2015-10-14 09:16:28 -07:00

View File

@@ -37,12 +37,15 @@ namespace Orchard.Commands.Builtin {
[CommandHelp("help <command>\r\n\t" + "Display help text for <command>")]
public void SingleCommand(string[] commandNameStrings) {
string command = string.Join(" ", commandNameStrings);
var descriptor = _commandManager.GetCommandDescriptors().SingleOrDefault(d => string.Equals(command, d.Name, StringComparison.OrdinalIgnoreCase));
if (descriptor == null) {
var descriptors = _commandManager.GetCommandDescriptors().Where(t => t.Name.StartsWith(command, StringComparison.OrdinalIgnoreCase)).OrderBy(d => d.Name);
if (!descriptors.Any()) {
Context.Output.WriteLine(T("Command {0} doesn't exist").ToString(), command);
}
else {
Context.Output.WriteLine(GetHelpText(descriptor));
foreach (var descriptor in descriptors) {
Context.Output.WriteLine(GetHelpText(descriptor));
Context.Output.WriteLine();
}
}
}
}