Skip to content

Commit

Permalink
Command names should be lower-case by default.
Browse files Browse the repository at this point in the history
  • Loading branch information
mayuki committed Jan 15, 2020
1 parent 61bfdfb commit f9f25a7
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/Cocona/Command/BuiltIn/CoconaBuiltInCommandProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,16 @@ public CommandCollection GetCommandCollection()
private CommandCollection GetCommandCollectionCore()
{
var commandCollection = _underlyingCommandProvider.GetCommandCollection();
var commands = commandCollection.All;

// If the collection has multiple-commands without primary command, use built-in primary command.
if (commandCollection.All.Count() > 1 && commandCollection.Primary == null)
{
return new CommandCollection(commandCollection.All.Concat(new[] { BuiltInPrimaryCommand.GetCommand(string.Empty) }).ToArray());
commands = commands.Concat(new[] { BuiltInPrimaryCommand.GetCommand(string.Empty) }).ToArray();
}

return commandCollection;
// Rewrite all command names as lower-case.
return new CommandCollection(commands.Select(x => new CommandDescriptor(x.Method, x.Name.ToLower(), x.Aliases, x.Description, x.Parameters, x.Overloads, x.IsPrimaryCommand)).ToArray());
}
}
}

0 comments on commit f9f25a7

Please sign in to comment.