Command line argument parsing improvements (#1048)

* Support negative numbers as command option values
* Support command line options before arguments
* POSIX-compliant handling of quotes (double and single, terminated and unterminated), whitespace, hyphens, and special characters (e.g. emojis)
This commit is contained in:
Frank Ray
2022-12-05 00:07:53 +00:00
committed by GitHub
parent f895bb175d
commit b793482ebb
14 changed files with 812 additions and 326 deletions

View File

@ -91,11 +91,6 @@ public sealed class CommandParseException : CommandRuntimeException
return CommandLineParseExceptionFactory.Create(reader.Original, token, "Invalid long option name.", "Invalid character.");
}
internal static CommandParseException UnterminatedQuote(string input, CommandTreeToken token)
{
return CommandLineParseExceptionFactory.Create(input, token, $"Encountered unterminated quoted string '{token.Value}'.", "Did you forget the closing quotation mark?");
}
internal static CommandParseException UnknownCommand(CommandModel model, CommandTree? node, IEnumerable<string> args, CommandTreeToken token)
{
var suggestion = CommandSuggestor.Suggest(model, node?.Command, token.Value);