mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-06-19 21:38:16 +08:00

* Renames Spectre.Cli to Spectre.Console.Cli. * Now uses Verify with Spectre.Console.Cli tests. * Removes some duplicate definitions. Closes #168
22 lines
674 B
C#
22 lines
674 B
C#
using System.Linq;
|
|
|
|
namespace Spectre.Console.Cli.Internal
|
|
{
|
|
internal static class CommandContainerExtensions
|
|
{
|
|
public static CommandInfo? FindCommand(this ICommandContainer root, string name, CaseSensitivity sensitivity)
|
|
{
|
|
var result = root.Commands.FirstOrDefault(
|
|
c => c.Name.Equals(name, sensitivity.GetStringComparison(CommandPart.CommandName)));
|
|
|
|
if (result == null)
|
|
{
|
|
result = root.Commands.FirstOrDefault(
|
|
c => c.Aliases.Contains(name, sensitivity.GetStringComparer(CommandPart.CommandName)));
|
|
}
|
|
|
|
return result;
|
|
}
|
|
}
|
|
}
|