diff --git a/src/Vertical/CommandLine/Parsing/TokenMatcher.cs b/src/Vertical/CommandLine/Parsing/TokenMatcher.cs index f4d55d8..fa29357 100644 --- a/src/Vertical/CommandLine/Parsing/TokenMatcher.cs +++ b/src/Vertical/CommandLine/Parsing/TokenMatcher.cs @@ -26,7 +26,7 @@ public sealed class TokenMatcher : ITokenMatcher private static readonly string CompactShortOptionPattern = $"^-(?<{TemplateIdGroup}>[0-9a-zA-Z]+)$"; private static readonly string LongOptionPattern = $"^--(?<{TemplateIdGroup}>[\\w-]+)$"; private static readonly string WordPattern = $"^(?![\\W])(?<{TemplateIdGroup}>[0-9a-zA-Z-]+)$"; - private static readonly string CompositeOptionPattern = $"^--?(?<{TemplateIdGroup}>[0-9a-zA-Z]+)[=:](?<{OperandGroup}>.+)?$"; + private static readonly string CompositeOptionPattern = $"^--?(?<{TemplateIdGroup}>[\\w-]+)[=:](?<{OperandGroup}>.+)?$"; private const string OptionsEndPattern = "^--$"; private const string AnyPattern = ".+"; diff --git a/test/Parsing/TokenMatcherTests.cs b/test/Parsing/TokenMatcherTests.cs index aae9ef2..176ffc5 100644 --- a/test/Parsing/TokenMatcherTests.cs +++ b/test/Parsing/TokenMatcherTests.cs @@ -37,7 +37,9 @@ public void PositiveMatchReturnsTokens(TokenMatcher matcher, string input, Token Scenario(TokenMatcher.CompositeOption, "-a:", new[]{ new Token(TokenType.CompositeOption, "a")}), Scenario(TokenMatcher.CompositeOption, "-a=", new[]{ new Token(TokenType.CompositeOption, "a")}), Scenario(TokenMatcher.CompositeOption, "--long=", new[]{ new Token(TokenType.CompositeOption, "long")}), - Scenario(TokenMatcher.CompositeOption, "--long:", new[]{ new Token(TokenType.CompositeOption, "long")}) + Scenario(TokenMatcher.CompositeOption, "--long:", new[]{ new Token(TokenType.CompositeOption, "long")}), + Scenario(TokenMatcher.CompositeOption, "--long-with-dashes:", new[]{ new Token(TokenType.CompositeOption, "long-with-dashes")}), + Scenario(TokenMatcher.CompositeOption, "--long-with-dashes=", new[]{ new Token(TokenType.CompositeOption, "long-with-dashes")}) ); [Theory, MemberData(nameof(NegativeTheories))]