From 747792f68d2d5dc9bd61a8a0611a14a8c72f026b Mon Sep 17 00:00:00 2001 From: Dan Date: Thu, 9 Dec 2021 16:59:10 -0700 Subject: [PATCH] Fixes #49 --- src/Vertical/CommandLine/Parsing/TokenMatcher.cs | 2 +- test/Parsing/TokenMatcherTests.cs | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) 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))]