From 79f115b1ef475b6bc12d21b1b8c6ac2f5649d6b1 Mon Sep 17 00:00:00 2001 From: gsscoder Date: Tue, 26 Feb 2013 16:46:37 +0100 Subject: [PATCH] Minor internal refactoring; snk placed out of csproj(s). --- .../CommandLine.snk => CommandLine.snk | Bin src/libcmdline/CommandLine.PublicKey | Bin 160 -> 0 bytes src/libcmdline/CommandLine.csproj | 281 +++++++++--------- src/libcmdline/Parsing/LongOptionParser.cs | 4 +- src/libcmdline/Parsing/OptionGroupParser.cs | 23 +- src/libcmdline/Parsing/PresentParserState.cs | 3 + src/tests/CommandLine.Tests.csproj | 267 +++++++++-------- src/tests/CommandLine.snk | Bin 596 -> 0 bytes src/tests/MyClass.cs | 11 - 9 files changed, 291 insertions(+), 298 deletions(-) rename src/libcmdline/CommandLine.snk => CommandLine.snk (100%) delete mode 100644 src/libcmdline/CommandLine.PublicKey delete mode 100644 src/tests/CommandLine.snk delete mode 100644 src/tests/MyClass.cs diff --git a/src/libcmdline/CommandLine.snk b/CommandLine.snk similarity index 100% rename from src/libcmdline/CommandLine.snk rename to CommandLine.snk diff --git a/src/libcmdline/CommandLine.PublicKey b/src/libcmdline/CommandLine.PublicKey deleted file mode 100644 index 72dffe9dc9e44fa012dd4c144d1acfd738f11e8a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 160 zcmV;R0AK$ABme*efB*oL000060ssI2Bme+XQ$aBR1ONa50096M>veI~mcVslcrf`! ziD?i!!&hWRd)v(X2vG9-=8-<)Gu7A6JG{7X{X*ub%!F-lYh3R&IG$UO1sRdP8a) diff --git a/src/libcmdline/CommandLine.csproj b/src/libcmdline/CommandLine.csproj index 63121a48..4ff14204 100644 --- a/src/libcmdline/CommandLine.csproj +++ b/src/libcmdline/CommandLine.csproj @@ -1,148 +1,147 @@ - - - - Debug - AnyCPU - 9.0.30729 - 2.0 - {5DEA2811-2FFA-4959-830B-CAD3ACACABEB} - Library - Properties - CommandLine - CommandLine - - - 3.5 - - - false - publish\ - true - Disk - false - Foreground - 7 - Days - false - false - true - 0 - 1.0.0.%2a - false - true - - - true - full - false - bin\Debug\ - TRACE;DEBUG - prompt - 4 - bin\Debug\CommandLine.XML - - - pdbonly - true - bin\Release\ - - - prompt - 4 - bin\Release\CommandLine.XML - true - - - true - - - CommandLine.snk - - - - - - - Properties\SharedAssemblyInfo.cs - - - - - - - - - - - - - - - True - True - SR.tt - - - - - - - - Code - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + Debug + AnyCPU + 9.0.30729 + 2.0 + {5DEA2811-2FFA-4959-830B-CAD3ACACABEB} + Library + Properties + CommandLine + CommandLine + + + 3.5 + + + false + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + true + + + true + full + false + bin\Debug\ + TRACE;DEBUG + prompt + 4 + bin\Debug\CommandLine.XML + + + pdbonly + true + bin\Release\ + + + prompt + 4 + bin\Release\CommandLine.XML + true + + + true + + + ..\..\CommandLine.snk + + + + + + + Properties\SharedAssemblyInfo.cs + + + + + + + + + + + + + + + True + True + SR.tt + + + + + + + + Code + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - TextTemplatingFileGenerator - SR.strings.cs - - - - - - - - - - - - + --> + + + TextTemplatingFileGenerator + SR.strings.cs + + + + + + + + + + + + \ No newline at end of file diff --git a/src/libcmdline/Parsing/LongOptionParser.cs b/src/libcmdline/Parsing/LongOptionParser.cs index f80fb1b9..af4ba2a5 100644 --- a/src/libcmdline/Parsing/LongOptionParser.cs +++ b/src/libcmdline/Parsing/LongOptionParser.cs @@ -37,7 +37,7 @@ public override PresentParserState Parse(IArgumentEnumerator argumentEnumerator, { var parts = argumentEnumerator.Current.Substring(2).Split(new[] { '=' }, 2); var option = map[parts[0]]; - bool valueSetting; + if (option == null) { return _ignoreUnkwnownArguments ? PresentParserState.MoveOnNextElement : PresentParserState.Failure; @@ -47,6 +47,8 @@ public override PresentParserState Parse(IArgumentEnumerator argumentEnumerator, ArgumentParser.EnsureOptionArrayAttributeIsNotBoundToScalar(option); + bool valueSetting; + if (!option.IsBoolean) { if (parts.Length == 1 && (argumentEnumerator.IsLast || !ArgumentParser.IsInputValue(argumentEnumerator.Next))) diff --git a/src/libcmdline/Parsing/OptionGroupParser.cs b/src/libcmdline/Parsing/OptionGroupParser.cs index 5e329d3d..9199b914 100644 --- a/src/libcmdline/Parsing/OptionGroupParser.cs +++ b/src/libcmdline/Parsing/OptionGroupParser.cs @@ -35,10 +35,11 @@ public OptionGroupParser(bool ignoreUnkwnownArguments) public override PresentParserState Parse(IArgumentEnumerator argumentEnumerator, OptionMap map, object options) { - IArgumentEnumerator group = new OneCharStringEnumerator(argumentEnumerator.Current.Substring(1)); - while (group.MoveNext()) + var optionGroup = new OneCharStringEnumerator(argumentEnumerator.Current.Substring(1)); + + while (optionGroup.MoveNext()) { - var option = map[group.Current]; + var option = map[optionGroup.Current]; if (option == null) { return _ignoreUnkwnownArguments ? PresentParserState.MoveOnNextElement : PresentParserState.Failure; @@ -50,17 +51,17 @@ public override PresentParserState Parse(IArgumentEnumerator argumentEnumerator, if (!option.IsBoolean) { - if (argumentEnumerator.IsLast && group.IsLast) + if (argumentEnumerator.IsLast && optionGroup.IsLast) { return PresentParserState.Failure; } bool valueSetting; - if (!group.IsLast) + if (!optionGroup.IsLast) { if (!option.IsArray) { - valueSetting = option.SetValue(group.GetRemainingFromNext(), options); + valueSetting = option.SetValue(optionGroup.GetRemainingFromNext(), options); if (!valueSetting) { DefineOptionThatViolatesFormat(option); @@ -72,7 +73,7 @@ public override PresentParserState Parse(IArgumentEnumerator argumentEnumerator, ArgumentParser.EnsureOptionAttributeIsArrayCompatible(option); var items = ArgumentParser.GetNextInputValues(argumentEnumerator); - items.Insert(0, @group.GetRemainingFromNext()); + items.Insert(0, optionGroup.GetRemainingFromNext()); valueSetting = option.SetValue(items, options); if (!valueSetting) @@ -112,10 +113,10 @@ public override PresentParserState Parse(IArgumentEnumerator argumentEnumerator, return ArgumentParser.BooleanToParserState(valueSetting); } - if (!@group.IsLast && map[@group.Next] == null) - { - return PresentParserState.Failure; - } + if (!optionGroup.IsLast && map[optionGroup.Next] == null) + { + return PresentParserState.Failure; + } if (!option.SetValue(true, options)) { diff --git a/src/libcmdline/Parsing/PresentParserState.cs b/src/libcmdline/Parsing/PresentParserState.cs index 6f64fb4e..5659dedc 100644 --- a/src/libcmdline/Parsing/PresentParserState.cs +++ b/src/libcmdline/Parsing/PresentParserState.cs @@ -31,8 +31,11 @@ namespace CommandLine.Parsing internal enum PresentParserState : ushort { Undefined = 0x00, + Success = 0x01, + Failure = 0x02, + MoveOnNextElement = 0x04 } } \ No newline at end of file diff --git a/src/tests/CommandLine.Tests.csproj b/src/tests/CommandLine.Tests.csproj index e66a91cb..c4ab9ed0 100644 --- a/src/tests/CommandLine.Tests.csproj +++ b/src/tests/CommandLine.Tests.csproj @@ -1,135 +1,134 @@ - - - - Debug - AnyCPU - 10.0.0 - 2.0 - {86E1AC34-ED2D-4E42-8B95-65208FEA36C2} - Library - CommandLine.Tests - CommandLine.Tests - ..\..\ - true - - - true - full - false - bin\Debug - TRACE;DEBUG - prompt - 4 - false - - - none - false - bin\Release - prompt - 4 - false - UNIT_TESTS - - - true - - - CommandLine.snk - - - - ..\..\packages\FluentAssertions.2.0.0.1\lib\net40\FluentAssertions.dll - - - - - - ..\..\packages\xunit.1.9.1\lib\net20\xunit.dll - - - - - Properties\SharedAssemblyInfo.cs - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {5DEA2811-2FFA-4959-830B-CAD3ACACABEB} - CommandLine - - - - - + + + + Debug + AnyCPU + 10.0.0 + 2.0 + {86E1AC34-ED2D-4E42-8B95-65208FEA36C2} + Library + CommandLine.Tests + CommandLine.Tests + ..\..\ + true + + + true + full + false + bin\Debug + TRACE;DEBUG + prompt + 4 + false + + + none + false + bin\Release + prompt + 4 + false + UNIT_TESTS + + + true + + + ..\..\CommandLine.snk + + + + ..\..\packages\FluentAssertions.2.0.0.1\lib\net40\FluentAssertions.dll + + + + + + ..\..\packages\xunit.1.9.1\lib\net20\xunit.dll + + + + + Properties\SharedAssemblyInfo.cs + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {5DEA2811-2FFA-4959-830B-CAD3ACACABEB} + CommandLine + + + + + \ No newline at end of file diff --git a/src/tests/CommandLine.snk b/src/tests/CommandLine.snk deleted file mode 100644 index c97645bdd8b012f2658c1762d000737a21831e2c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 596 zcmV-a0;~N80ssI2Bme+XQ$aES1ONa50096M>veI~mcVslcrf`!iD?i!!&hWRd)v(X z2vG9-=8-<)Gu7A6JG{7X{X*ub%!F-lYh3R&IG$UO1sRdNSzz+GKvhPVu0vD2Ya^gx`v z<6kYi+V$6dn=DR;3xyNavf()^D$chN+b+a1B2Ezi`I1wo+}t z#Y#%lak-j!aQphazjcxflN%WMU6YXr$Kj=k*o=85I9yXB{kWLk*qg(jr!zMG+%xZW zK15(d>q{<3`9bsA1Oj0)k&{Racftv*#|HDR*$lyUlK@tE$hVLa_HxN#72jF%K9a{p zzeKUi+ZYCcL?>89vSLS6BM(3rPnq1HF6#neLKSkdqFqJGwsy=Fzje>fvu6lPBkTT9#ov09$DJ`Shw}llN-kips5VfZi3W!s7^aT#8DE~K*#=ADmA!g i;-fp@M`%kb=DLu8fY~iOYQm{9j3Y@0a%yC1G7Y47#2^p= diff --git a/src/tests/MyClass.cs b/src/tests/MyClass.cs deleted file mode 100644 index 463148ed..00000000 --- a/src/tests/MyClass.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System; -namespace CommandLine.Tests -{ - public class MyClass - { - public MyClass () - { - } - } -} -