private static string TryGetMatchingPrefix(ArgumentDescriptor descriptor, string argument)
{
Debug.Assert(descriptor.Prefixes.Count(p => argument.StartsWith(p, ArgumentDescriptor.IdComparison)) < 2,
"Not expecting the argument to match multiple prefixes");
string match;
if (descriptor.IsVerb)
{
// Verbs match the whole argument
match = descriptor.Prefixes.FirstOrDefault(p => ArgumentDescriptor.IdComparer.Equals(p, argument));
}
else
{
// Prefixes only match the start
match = descriptor.Prefixes.FirstOrDefault(p => argument.StartsWith(p, ArgumentDescriptor.IdComparison));
}
return match;
}