mirror of
https://github.com/nsnail/spectre.console.git
synced 2025-06-19 21:38:16 +08:00
Allow using -? as a shorthand for -h
Given that it's quite a common switch and extremely unlikely to be already in use for something else, we can just consider it to be the same as having entered `-h` as an arg. This adds the `?` as a valid option character name. Fixes #1547
This commit is contained in:

committed by
Patrik Svensson

parent
0e2ed511a5
commit
5c87d7fa04
@ -86,7 +86,7 @@ internal static class TemplateParser
|
||||
|
||||
foreach (var character in token.Value)
|
||||
{
|
||||
if (!char.IsLetterOrDigit(character) && character != '-' && character != '_')
|
||||
if (!char.IsLetterOrDigit(character) && character != '-' && character != '_' && character != '?')
|
||||
{
|
||||
throw CommandTemplateException.InvalidCharacterInOptionName(template, token, character);
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ internal class CommandTreeParser
|
||||
{
|
||||
_configuration = configuration ?? throw new ArgumentNullException(nameof(configuration));
|
||||
_parsingMode = parsingMode ?? _configuration.ParsingMode;
|
||||
_help = new CommandOptionAttribute("-h|--help");
|
||||
_help = new CommandOptionAttribute("-?|-h|--help");
|
||||
_convertFlagsToRemainingArguments = convertFlagsToRemainingArguments ?? false;
|
||||
|
||||
CaseSensitivity = caseSensitivity;
|
||||
|
@ -176,7 +176,7 @@ internal static class CommandTreeTokenizer
|
||||
break;
|
||||
}
|
||||
|
||||
if (char.IsLetter(current))
|
||||
if (char.IsLetter(current) || current is '?')
|
||||
{
|
||||
context.AddRemaining(current);
|
||||
reader.Read(); // Consume
|
||||
|
Reference in New Issue
Block a user