├── .gitignore ├── .nuget ├── NuGet.Config ├── NuGet.exe ├── NuGet.targets └── packages.config ├── FluentCommandLineParser.Examples ├── App.config ├── FluentCommandLineParser.Examples.csproj ├── Program.cs └── Properties │ └── AssemblyInfo.cs ├── FluentCommandLineParser.Signed.nuspec ├── FluentCommandLineParser.Tests ├── CommandLineOptionFormatterTests.cs ├── Commands │ ├── AddArgs.cs │ ├── CommandTests.cs │ └── RemoveArgs.cs ├── Extensions │ └── StringExtensions.cs ├── FluentCommandLineParser.Tests.XUnit.msbuild ├── FluentCommandLineParser.Tests.csproj ├── FluentCommandLineParser │ ├── Behaviour │ │ └── InvalidOptionSetupBehaviour.cs │ ├── TestContext │ │ ├── FluentCommandLineParserTestContext.cs │ │ ├── SettingUpALongOptionTestContext.cs │ │ ├── SettingUpAShortOptionTestContext.cs │ │ ├── TestEnum.cs │ │ ├── TestEnumFlag.cs │ │ ├── TestException.cs │ │ └── TestType.cs │ ├── when_a_new_instance_is_created.cs │ ├── when_executing_parse_operation │ │ ├── with_a_parser_engine_that_is_custom.cs │ │ ├── with_a_parser_engine_that_is_null.cs │ │ ├── with_options_that_are_not_specified_in_the_args.cs │ │ ├── with_options_that_are_specified_in_the_args.cs │ │ └── with_options_that_have_not_been_setup.cs │ ├── when_setting_up_a_new_option │ │ ├── and_the_option_factory │ │ │ ├── returns_a_null_option.cs │ │ │ └── throws_an_error.cs │ │ ├── with_a_long_name │ │ │ ├── with_a_long_name.cs │ │ │ ├── with_a_long_name_that_contains_a_colon.cs │ │ │ ├── with_a_long_name_that_contains_an_equality_sign.cs │ │ │ ├── with_a_long_name_that_contains_whitespace.cs │ │ │ ├── with_a_long_name_that_is_already_used.cs │ │ │ ├── with_a_long_name_that_is_already_used_but_differs_by_case.cs │ │ │ ├── with_a_long_name_that_is_empty.cs │ │ │ ├── with_a_long_name_that_is_valid.cs │ │ │ └── with_a_long_name_that_is_whitespace.cs │ │ └── with_a_short_name │ │ │ ├── with_a_short_name.cs │ │ │ ├── with_a_short_name_that_contains_a_colon.cs │ │ │ ├── with_a_short_name_that_contains_an_equality_sign.cs │ │ │ ├── with_a_short_name_that_contains_whitespace.cs │ │ │ ├── with_a_short_name_that_is_a_control_char.cs │ │ │ ├── with_a_short_name_that_is_already_used.cs │ │ │ ├── with_a_short_name_that_is_already_used_but_differs_by_case.cs │ │ │ └── with_a_short_name_that_is_whitespace.cs │ └── when_using_an_option_factory │ │ ├── that_has_been_set_to_null.cs │ │ └── that_is_custom.cs ├── FluentCommandLineParserBuilderTests.cs ├── FluentCommandLineParserMSpecTests.cs ├── FluentCommandLineParserTests.cs ├── HelperExtensions.cs ├── Integration │ ├── BoolInlineDataAttribute.cs │ ├── DoubleInlineDataAttribute.cs │ ├── EnumInlineDataAttribute.cs │ ├── Int32EnumInlineDataAttribute.cs │ ├── Int32InlineDataAttribute.cs │ ├── Int64InlineDataAttribute.cs │ ├── IntegrationTests.cs │ ├── Lists │ │ ├── ArgumentInlineDataAttribute.cs │ │ ├── BoolListInlineDataAttribute.cs │ │ ├── DoubleListInlineDataAttribute.cs │ │ ├── EnumFlagListInlineDataAttribute .cs │ │ ├── EnumListInlineDataAttribute.cs │ │ ├── FlagTests.cs │ │ ├── Int32ListInlineDataAttribute.cs │ │ ├── Int64ListInlineDataAttribute.cs │ │ ├── ListTests.cs │ │ └── StringListInlineDataAttribute.cs │ ├── NCrunchExcelDataAttribute.cs │ ├── SimpleShortOptionsAreParsedCorrectlyAttribute.cs │ └── StringInlineDataAttribute.cs ├── Internals │ ├── AnonymousMock.cs │ ├── CommandLineOptionFactoryTests.cs │ ├── CommandLineOptionGrouperTests.cs │ ├── CommandLineOptionParserFactoryTests.cs │ ├── CommandLineOptionTests.cs │ ├── CommandLineParserEngine │ │ ├── Behaviour │ │ │ └── NoResultsBehaviour.cs │ │ ├── TestContext │ │ │ └── CommandLineParserEngineTestContext.cs │ │ ├── when_a_new_instance_is_created.cs │ │ ├── when_arg_contains_key_and_value_assignment_but_no_value.cs │ │ ├── when_args_contains_a_boolean_option_that_ends_with_no_sign.cs │ │ ├── when_specified_args_are_empty.cs │ │ ├── when_specified_args_are_null.cs │ │ └── when_specified_args_contain_no_keys.cs │ ├── CommandLineParserEngineMark2Tests.cs │ ├── CommandLineParserEngineMark2TestsXUnit.cs │ ├── Errors │ │ └── ExpectedOptionNotFoundParseErrorTests.cs │ ├── HelpCommandLineOptionTests.cs │ ├── TestContextBase.cs │ ├── UsefulExtensionTests.cs │ └── Validators │ │ ├── NoDuplicateOptionValidatorTests.cs │ │ └── OptionNameValidatorTests.cs ├── Mspec │ ├── CommandLineParserEngine │ │ ├── Behaviour │ │ │ └── NoResultsBehaviour.cs │ │ └── TestContext │ │ │ └── CommandLineParserEngineTestContext.cs │ └── Subjects.cs ├── Properties │ └── AssemblyInfo.cs ├── TestApplicationArgs.cs ├── TestContext │ └── TestContext.cs ├── UriTests.cs ├── app.config └── packages.config ├── FluentCommandLineParser.sln ├── FluentCommandLineParser ├── CommandAlreadyExistsException.cs ├── CommandLineCommand.cs ├── CommandLineParserErrorFormatter.cs ├── CommandNotFoundException.cs ├── FluentCommandLineBuilderT.cs ├── FluentCommandLineParser.cs ├── FluentCommandLineParser.csproj ├── FluentCommandLineParser.nuspec ├── FluentCommandLineParserT.cs ├── ICommandLineCommand.cs ├── ICommandLineOptionBuilderFluent.cs ├── ICommandLineOptionFluent.cs ├── ICommandLineOptionFormatter.cs ├── ICommandLineParserError.cs ├── ICommandLineParserErrorFormatter.cs ├── ICommandLineParserResult.cs ├── IFluentCommandLineBuilderT.cs ├── IFluentCommandLineParser.cs ├── IFluentCommandLineParserT.cs ├── IHelpCommandLineOptionFluent.cs ├── Internals │ ├── CommandLineOption.cs │ ├── CommandLineOptionBuilderFluent.cs │ ├── CommandLineOptionFactory.cs │ ├── CommandLineOptionFormatter.cs │ ├── EmptyHelpCommandLineOption.cs │ ├── Errors │ │ ├── CommandLineParserErrorBase.cs │ │ ├── ExpectedOptionNotFoundParseError.cs │ │ └── OptionSyntaxParseError.cs │ ├── Extensions │ │ └── UsefulExtension.cs │ ├── HelpCommandLineOption.cs │ ├── ICommandLineOption.cs │ ├── ICommandLineOptionFactory.cs │ ├── ICommandLineOptionResult.cs │ ├── IHelpCommandLineOption.cs │ ├── IHelpCommandLineOptionResult.cs │ ├── Parsing │ │ ├── CommandLineOptionGrouper.cs │ │ ├── CommandLineParserEngineMark2.cs │ │ ├── CommandLineParserResult.cs │ │ ├── ICommandLineOptionParserFactory.cs │ │ ├── ICommandLineParserEngine.cs │ │ ├── OptionArgumentParser.cs │ │ ├── OptionParsers │ │ │ ├── BoolCommandLineOptionParser.cs │ │ │ ├── CommandLineOptionParserFactory.cs │ │ │ ├── DateTimeCommandLineOptionParser.cs │ │ │ ├── DoubleCommandLineOptionParser.cs │ │ │ ├── EnumCommandLineOptionParser.cs │ │ │ ├── EnumFlagCommandLineOptionParser.cs │ │ │ ├── ICommandLineOptionParser.cs │ │ │ ├── Int32CommandLineOptionParser.cs │ │ │ ├── Int64CommandLineOptionParser.cs │ │ │ ├── ListCommandLineOptionParser.cs │ │ │ ├── NullableBoolCommandLineOptionParser.cs │ │ │ ├── NullableCommandLineOptionParser.cs │ │ │ ├── NullableEnumCommandLineOptionParser.cs │ │ │ ├── StringCommandLineOptionParser.cs │ │ │ ├── TimeSpanCommandLineOptionParser.cs │ │ │ └── UriCommandLineOptionParser.cs │ │ ├── ParsedOption.cs │ │ ├── ParsedOptionFactory.cs │ │ └── ParserEngineResult.cs │ ├── SpecialCharacters.cs │ └── Validators │ │ ├── CommandLineOptionValidator.cs │ │ ├── ICommandLineOptionValidator.cs │ │ ├── NoDuplicateOptionValidator.cs │ │ └── OptionNameValidator.cs ├── InvalidOptionNameException.cs ├── OptionAlreadyExistsException.cs ├── OptionSyntaxException.cs ├── ParseSequence.cs ├── Properties │ └── AssemblyInfo.cs └── UnsupportedTypeException.cs ├── LICENCE.txt └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | *.suo 2 | *.user 3 | _ReSharper.* 4 | bin 5 | obj 6 | packages/* 7 | !repositories.config 8 | packages/ 9 | _ncrunch* 10 | *.ncrunch* 11 | .vs/ 12 | -------------------------------------------------------------------------------- /.nuget/NuGet.Config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.nuget/NuGet.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fclp/fluent-command-line-parser/eec17c799a09b842deb8e8ae2030f2f0d366d435/.nuget/NuGet.exe -------------------------------------------------------------------------------- /.nuget/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /FluentCommandLineParser.Examples/App.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /FluentCommandLineParser.Examples/Program.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace Fclp.Examples 4 | { 5 | class CommandProgram 6 | { 7 | // Contains all arguments for the add command 8 | class AddArgs 9 | { 10 | public bool Verbose { get; set; } 11 | public bool IgnoreErrors { get; set; } 12 | public List Files { get; set; } 13 | public List Files2 { get; set; } 14 | } 15 | 16 | // Contains all arguments for the remove command 17 | class RemoveArgs 18 | { 19 | public bool Verbose { get; set; } 20 | public List Files { get; set; } 21 | } 22 | 23 | static void Main(string[] args) 24 | { 25 | var fclp = new FluentCommandLineParser(); 26 | 27 | // use new SetupCommand method to initialise a command 28 | var addCmd = fclp.SetupCommand("add") 29 | .OnSuccess(Add); // executed when the add command is used 30 | 31 | // the standard fclp framework, except against the created command rather than the fclp itself 32 | addCmd.Setup(addArgs => addArgs.Verbose) 33 | .As('v', "verbose") 34 | .SetDefault(false) 35 | .WithDescription("Be verbose"); 36 | 37 | addCmd.Setup(addArgs => addArgs.IgnoreErrors) 38 | .As("ignore-errors") 39 | .SetDefault(false) 40 | .WithDescription("If some files could not be added, do not abort"); 41 | 42 | addCmd.Setup(addArgs => addArgs.Files) 43 | .As('f', "files") 44 | .WithDescription("Files to be tracked") 45 | .UseForOrphanArguments(); 46 | 47 | // add the remove command 48 | var remCmd = fclp.SetupCommand("rem") 49 | .OnSuccess(Remove); // executed when the remove command is used 50 | 51 | remCmd.Setup(removeArgs => removeArgs.Verbose) 52 | .As('v', "verbose") 53 | .SetDefault(false) 54 | .WithDescription("Be verbose"); 55 | 56 | remCmd.Setup(removeArgs => removeArgs.Files) 57 | .As('f', "files") 58 | .WithDescription("Files to be untracked") 59 | .UseForOrphanArguments(); 60 | 61 | fclp.Parse(args); 62 | } 63 | 64 | static void Add(AddArgs args) 65 | { 66 | // add was executed 67 | } 68 | 69 | static void Remove(RemoveArgs args) 70 | { 71 | // remove was executed 72 | } 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /FluentCommandLineParser.Examples/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("FluentCommandLineParser.Examples")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("FluentCommandLineParser.Examples")] 13 | [assembly: AssemblyCopyright("Copyright © 2015")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("e5d3cab1-0e75-42ba-b39a-516de3b732a6")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /FluentCommandLineParser.Signed.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | FluentCommandLineParser.Signed 5 | Fluent Command Line Parser (Signed) 6 | 1.0.0 7 | siywilliams 8 | siywilliams 9 | https://github.com/fclp/fluent-command-line-parser/blob/develop/LICENCE.txt 10 | http://fclp.github.com/fluent-command-line-parser 11 | https://avatars0.githubusercontent.com/u/3839783 12 | false 13 | A simple, strongly typed .NET C# command line parser library using a fluent easy to use interface 14 | https://github.com/fclp/fluent-command-line-parser/wiki/Roadmap 15 | Copyright Simon Williams 2012 - 2017 16 | fluent command line parser commandline c# net35 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /FluentCommandLineParser.Tests/Commands/AddArgs.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace Fclp.Tests.Commands 4 | { 5 | class AddArgs 6 | { 7 | public bool Verbose { get; set; } 8 | public bool IgnoreErrors { get; set; } 9 | public List Files { get; set; } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /FluentCommandLineParser.Tests/Commands/RemoveArgs.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | 3 | namespace Fclp.Tests.Commands 4 | { 5 | class RemoveArgs 6 | { 7 | public bool Verbose { get; set; } 8 | public List Files { get; set; } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /FluentCommandLineParser.Tests/Extensions/StringExtensions.cs: -------------------------------------------------------------------------------- 1 | using System.Linq; 2 | using Fclp.Internals.Extensions; 3 | 4 | namespace Fclp.Tests.Extensions 5 | { 6 | public static class StringExtensions 7 | { 8 | public static string[] AsCmdArgs(this string args) 9 | { 10 | args = ReplaceWithDoubleQuotes(args); 11 | return args.SplitOnWhitespace().ToArray(); 12 | } 13 | 14 | private static string ReplaceWithDoubleQuotes(string args) 15 | { 16 | if (args == null) return null; 17 | return args.Replace('\'', '"'); 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /FluentCommandLineParser.Tests/FluentCommandLineParser.Tests.XUnit.msbuild: -------------------------------------------------------------------------------- 1 | 4 | 5 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /FluentCommandLineParser.Tests/FluentCommandLineParser/Behaviour/InvalidOptionSetupBehaviour.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | // InvalidOptionSetupBehaviour.cs 3 | // Copyright (c) 2013, Simon Williams 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without modification, are permitted provide 7 | // d that the following conditions are met: 8 | // 9 | // Redistributions of source code must retain the above copyright notice, this list of conditions and the 10 | // following disclaimer. 11 | // 12 | // Redistributions in binary form must reproduce the above copyright notice, this list of conditions and 13 | // the following disclaimer in the documentation and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED 16 | // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 17 | // PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 18 | // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 19 | // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 21 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 22 | // POSSIBILITY OF SUCH DAMAGE. 23 | #endregion 24 | 25 | using System; 26 | using Machine.Specifications; 27 | 28 | namespace Fclp.Tests.FluentCommandLineParser 29 | { 30 | namespace Behaviour 31 | { 32 | [Behaviors] 33 | public class InvalidOptionSetupBehaviour 34 | { 35 | protected static Fclp.FluentCommandLineParser sut; 36 | protected static Exception error; 37 | 38 | It should_throw_an_error = () => error.ShouldNotBeNull(); 39 | It should_throw_an_ArgumentOutOfRangeException = () => error.ShouldNotBeNull(); 40 | It should_not_have_setup_an_option = () => sut.Options.ShouldBeEmpty(); 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /FluentCommandLineParser.Tests/FluentCommandLineParser/TestContext/FluentCommandLineParserTestContext.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | // FluentCommandLineParserTestContext.cs 3 | // Copyright (c) 2013, Simon Williams 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without modification, are permitted provide 7 | // d that the following conditions are met: 8 | // 9 | // Redistributions of source code must retain the above copyright notice, this list of conditions and the 10 | // following disclaimer. 11 | // 12 | // Redistributions in binary form must reproduce the above copyright notice, this list of conditions and 13 | // the following disclaimer in the documentation and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED 16 | // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 17 | // PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 18 | // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 19 | // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 21 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 22 | // POSSIBILITY OF SUCH DAMAGE. 23 | #endregion 24 | 25 | using Fclp.Internals; 26 | using Fclp.Internals.Parsing; 27 | using Machine.Specifications; 28 | using Moq; 29 | 30 | namespace Fclp.Tests.FluentCommandLineParser 31 | { 32 | namespace TestContext 33 | { 34 | [Subject(typeof(Fclp.FluentCommandLineParser), "Unit Tests")] 35 | public abstract class FluentCommandLineParserTestContext : TestContext 36 | { 37 | private Establish context = () => { sut = new Fclp.FluentCommandLineParser(); }; 38 | 39 | protected static void AutoMockAll() 40 | { 41 | AutoMockEngineParser(); 42 | AutoMockOptionFactory(); 43 | } 44 | 45 | protected static void AutoMockEngineParser() 46 | { 47 | sut.ParserEngine = Mock.Of(); 48 | } 49 | 50 | protected static void AutoMockOptionFactory() 51 | { 52 | var mock = new Mock(); 53 | var mockOption = new Mock>(); 54 | 55 | mock.Setup(x => x.CreateOption(Moq.It.IsAny(), Moq.It.IsAny())) 56 | .Returns(mockOption.Object) 57 | .Callback((s, l) => 58 | { 59 | mockOption.SetupGet(x => x.ShortName).Returns(s); 60 | mockOption.SetupGet(x => x.LongName).Returns(l); 61 | }); 62 | 63 | 64 | sut.OptionFactory = mock.Object; 65 | } 66 | } 67 | } 68 | } -------------------------------------------------------------------------------- /FluentCommandLineParser.Tests/FluentCommandLineParser/TestContext/SettingUpALongOptionTestContext.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | // SettingUpALongOptionTestContext.cs 3 | // Copyright (c) 2013, Simon Williams 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without modification, are permitted provide 7 | // d that the following conditions are met: 8 | // 9 | // Redistributions of source code must retain the above copyright notice, this list of conditions and the 10 | // following disclaimer. 11 | // 12 | // Redistributions in binary form must reproduce the above copyright notice, this list of conditions and 13 | // the following disclaimer in the documentation and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED 16 | // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 17 | // PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 18 | // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 19 | // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 21 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 22 | // POSSIBILITY OF SUCH DAMAGE. 23 | #endregion 24 | 25 | using System.Linq; 26 | 27 | namespace Fclp.Tests.FluentCommandLineParser 28 | { 29 | namespace TestContext 30 | { 31 | public abstract class SettingUpALongOptionTestContext : SettingUpAShortOptionTestContext 32 | { 33 | protected const string valid_long_name_that_is_empty = ""; 34 | protected const string invalid_long_name_that_is_whitespace = " "; 35 | protected const string invalid_long_name_with_spaces = "long name"; 36 | protected const string invalid_long_name_with_colon = "long:name"; 37 | protected const string invalid_long_name_with_equality_sign = "long=name"; 38 | protected const string valid_long_name = "long"; 39 | 40 | protected static void SetupOptionWith(char shortName, string longName) 41 | { 42 | CatchAnyError(() => 43 | { 44 | var ret = sut.Setup(shortName, longName); 45 | option = sut.Options.SingleOrDefault(x => ReferenceEquals(x, ret)); 46 | }); 47 | } 48 | } 49 | } 50 | } -------------------------------------------------------------------------------- /FluentCommandLineParser.Tests/FluentCommandLineParser/TestContext/SettingUpAShortOptionTestContext.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | // SettingUpAShortOptionTestContext.cs 3 | // Copyright (c) 2013, Simon Williams 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without modification, are permitted provide 7 | // d that the following conditions are met: 8 | // 9 | // Redistributions of source code must retain the above copyright notice, this list of conditions and the 10 | // following disclaimer. 11 | // 12 | // Redistributions in binary form must reproduce the above copyright notice, this list of conditions and 13 | // the following disclaimer in the documentation and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED 16 | // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 17 | // PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 18 | // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 19 | // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 21 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 22 | // POSSIBILITY OF SUCH DAMAGE. 23 | #endregion 24 | 25 | using System.Linq; 26 | using Fclp.Internals; 27 | using Machine.Specifications; 28 | 29 | namespace Fclp.Tests.FluentCommandLineParser 30 | { 31 | namespace TestContext 32 | { 33 | [Subject(Subjects.setup_new_option)] 34 | public abstract class SettingUpAShortOptionTestContext : FluentCommandLineParserTestContext 35 | { 36 | protected const char invalid_short_name_that_is_whitespace = ' '; 37 | protected const char invalid_short_name_with_colon = ':'; 38 | protected const char invalid_short_name_with_equality_sign = '='; 39 | protected const char invalid_short_name_that_is_a_control_char = (char) 7; 40 | protected const char valid_short_name = 's'; 41 | 42 | protected static ICommandLineOption option; 43 | 44 | protected static void SetupOptionWith(char shortName) 45 | { 46 | CatchAnyError(() => 47 | { 48 | var ret = sut.Setup(shortName); 49 | option = sut.Options.SingleOrDefault(x => ReferenceEquals(x, ret)); 50 | }); 51 | } 52 | } 53 | } 54 | } -------------------------------------------------------------------------------- /FluentCommandLineParser.Tests/FluentCommandLineParser/TestContext/TestEnum.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | // TestEnum.cs 3 | // Copyright (c) 2014, Simon Williams 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without modification, are permitted provide 7 | // d that the following conditions are met: 8 | // 9 | // Redistributions of source code must retain the above copyright notice, this list of conditions and the 10 | // following disclaimer. 11 | // 12 | // Redistributions in binary form must reproduce the above copyright notice, this list of conditions and 13 | // the following disclaimer in the documentation and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED 16 | // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 17 | // PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 18 | // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 19 | // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 21 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 22 | // POSSIBILITY OF SUCH DAMAGE. 23 | #endregion 24 | 25 | namespace Fclp.Tests.FluentCommandLineParser 26 | { 27 | public enum TestEnum 28 | { 29 | Value0 = 0, 30 | Value1 = 1 31 | } 32 | } -------------------------------------------------------------------------------- /FluentCommandLineParser.Tests/FluentCommandLineParser/TestContext/TestEnumFlag.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace Fclp.Tests.FluentCommandLineParser 4 | { 5 | [Flags] 6 | public enum TestEnumFlag 7 | { 8 | Value0 = 0, 9 | Value1 = 1, 10 | Value2 = 2, 11 | Value4 = 4, 12 | Value8 = 8, 13 | Value16 = 16, 14 | Value32 = 32, 15 | Value64 = 64 16 | } 17 | } -------------------------------------------------------------------------------- /FluentCommandLineParser.Tests/FluentCommandLineParser/TestContext/TestException.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | // TestException.cs 3 | // Copyright (c) 2013, Simon Williams 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without modification, are permitted provide 7 | // d that the following conditions are met: 8 | // 9 | // Redistributions of source code must retain the above copyright notice, this list of conditions and the 10 | // following disclaimer. 11 | // 12 | // Redistributions in binary form must reproduce the above copyright notice, this list of conditions and 13 | // the following disclaimer in the documentation and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED 16 | // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 17 | // PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 18 | // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 19 | // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 21 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 22 | // POSSIBILITY OF SUCH DAMAGE. 23 | #endregion 24 | 25 | using System; 26 | 27 | namespace Fclp.Tests.FluentCommandLineParser 28 | { 29 | namespace TestContext 30 | { 31 | public class TestException : Exception 32 | { 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /FluentCommandLineParser.Tests/FluentCommandLineParser/TestContext/TestType.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | // TestType.cs 3 | // Copyright (c) 2013, Simon Williams 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without modification, are permitted provide 7 | // d that the following conditions are met: 8 | // 9 | // Redistributions of source code must retain the above copyright notice, this list of conditions and the 10 | // following disclaimer. 11 | // 12 | // Redistributions in binary form must reproduce the above copyright notice, this list of conditions and 13 | // the following disclaimer in the documentation and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED 16 | // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 17 | // PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 18 | // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 19 | // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 21 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 22 | // POSSIBILITY OF SUCH DAMAGE. 23 | #endregion 24 | namespace Fclp.Tests.FluentCommandLineParser 25 | { 26 | namespace TestContext 27 | { 28 | public class TestType 29 | { 30 | 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /FluentCommandLineParser.Tests/FluentCommandLineParser/when_a_new_instance_is_created.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | // when_a_new_instance_is_created.cs 3 | // Copyright (c) 2013, Simon Williams 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without modification, are permitted provide 7 | // d that the following conditions are met: 8 | // 9 | // Redistributions of source code must retain the above copyright notice, this list of conditions and the 10 | // following disclaimer. 11 | // 12 | // Redistributions in binary form must reproduce the above copyright notice, this list of conditions and 13 | // the following disclaimer in the documentation and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED 16 | // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 17 | // PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 18 | // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 19 | // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 21 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 22 | // POSSIBILITY OF SUCH DAMAGE. 23 | #endregion 24 | 25 | using Fclp.Internals; 26 | using Fclp.Internals.Parsing; 27 | using Fclp.Tests.FluentCommandLineParser.TestContext; 28 | using Machine.Specifications; 29 | 30 | namespace Fclp.Tests 31 | { 32 | namespace FluentCommandLineParser 33 | { 34 | public class when_a_new_instance_is_created : FluentCommandLineParserTestContext 35 | { 36 | It should_create_a_default_parser_engine = () => sut.ParserEngine.ShouldBeOfType(typeof(CommandLineParserEngineMark2)); 37 | It should_create_a_default_option_factory = () => sut.OptionFactory.ShouldBeOfType(typeof(CommandLineOptionFactory)); 38 | It should_set_the_string_comparison_to_current_culture = () => sut.StringComparison.ShouldEqual(System.StringComparison.CurrentCulture); 39 | It should_have_setup_no_options_internally = () => sut.Options.ShouldBeEmpty(); 40 | It should_have_a_default_option_formatter = () => sut.OptionFormatter.ShouldBeOfType(typeof(CommandLineOptionFormatter)); 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /FluentCommandLineParser.Tests/FluentCommandLineParser/when_executing_parse_operation/with_a_parser_engine_that_is_custom.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | // with_a_parser_engine_that_is_custom.cs 3 | // Copyright (c) 2013, Simon Williams 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without modification, are permitted provide 7 | // d that the following conditions are met: 8 | // 9 | // Redistributions of source code must retain the above copyright notice, this list of conditions and the 10 | // following disclaimer. 11 | // 12 | // Redistributions in binary form must reproduce the above copyright notice, this list of conditions and 13 | // the following disclaimer in the documentation and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED 16 | // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 17 | // PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 18 | // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 19 | // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 21 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 22 | // POSSIBILITY OF SUCH DAMAGE. 23 | #endregion 24 | 25 | using System.Collections.Generic; 26 | using Fclp.Internals.Parsing; 27 | using Fclp.Tests.FluentCommandLineParser.TestContext; 28 | using Machine.Specifications; 29 | using Moq; 30 | using It = Machine.Specifications.It; 31 | 32 | namespace Fclp.Tests.FluentCommandLineParser 33 | { 34 | namespace when_executing_parse_operation 35 | { 36 | public class with_a_parser_engine_that_is_custom : FluentCommandLineParserTestContext 37 | { 38 | static string[] args; 39 | static ICommandLineParserEngine customEngine { get { return mockedEngine.Object; } } 40 | static Mock mockedEngine; 41 | 42 | Establish context = () => 43 | { 44 | sut = new Fclp.FluentCommandLineParser(); 45 | mockedEngine = new Mock(); 46 | 47 | args = new string[0]; 48 | 49 | mockedEngine 50 | .Setup(x => x.Parse(args, false)) 51 | .Returns(Create()) 52 | .Verifiable(); 53 | }; 54 | 55 | Because of = () => 56 | { 57 | sut.ParserEngine = customEngine; 58 | sut.Parse(args); 59 | }; 60 | 61 | It should_replace_the_old_engine = () => sut.ParserEngine.ShouldBeTheSameAs(customEngine); 62 | It should_be_used_to_parse_the_args = () => mockedEngine.Verify(x => x.Parse(args, false)); 63 | } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /FluentCommandLineParser.Tests/FluentCommandLineParser/when_executing_parse_operation/with_a_parser_engine_that_is_null.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | // with_a_parser_engine_that_is_null.cs 3 | // Copyright (c) 2013, Simon Williams 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without modification, are permitted provide 7 | // d that the following conditions are met: 8 | // 9 | // Redistributions of source code must retain the above copyright notice, this list of conditions and the 10 | // following disclaimer. 11 | // 12 | // Redistributions in binary form must reproduce the above copyright notice, this list of conditions and 13 | // the following disclaimer in the documentation and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED 16 | // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 17 | // PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 18 | // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 19 | // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 21 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 22 | // POSSIBILITY OF SUCH DAMAGE. 23 | #endregion 24 | 25 | using Fclp.Internals.Parsing; 26 | using Fclp.Tests.FluentCommandLineParser.TestContext; 27 | using Machine.Specifications; 28 | 29 | namespace Fclp.Tests.FluentCommandLineParser 30 | { 31 | namespace when_executing_parse_operation 32 | { 33 | public class with_a_parser_engine_that_is_null : FluentCommandLineParserTestContext 34 | { 35 | Because of = () => sut.ParserEngine = null; 36 | 37 | It should_be_unable_to_assign_to_null = () => sut.ParserEngine.ShouldNotBeNull(); 38 | It should_use_the_default_one_instead = () => sut.ParserEngine.ShouldBeOfType(typeof(CommandLineParserEngineMark2)); 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /FluentCommandLineParser.Tests/FluentCommandLineParser/when_setting_up_a_new_option/and_the_option_factory/returns_a_null_option.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | // returns_a_null_option.cs 3 | // Copyright (c) 2013, Simon Williams 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without modification, are permitted provide 7 | // d that the following conditions are met: 8 | // 9 | // Redistributions of source code must retain the above copyright notice, this list of conditions and the 10 | // following disclaimer. 11 | // 12 | // Redistributions in binary form must reproduce the above copyright notice, this list of conditions and 13 | // the following disclaimer in the documentation and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED 16 | // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 17 | // PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 18 | // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 19 | // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 21 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 22 | // POSSIBILITY OF SUCH DAMAGE. 23 | #endregion 24 | 25 | using System; 26 | using System.Globalization; 27 | using Fclp.Internals; 28 | using Fclp.Tests.FluentCommandLineParser.TestContext; 29 | using Machine.Specifications; 30 | using Moq; 31 | using It = Machine.Specifications.It; 32 | 33 | namespace Fclp.Tests.FluentCommandLineParser.when_setting_up_a_new_option 34 | { 35 | namespace and_the_option_factory 36 | { 37 | public class returns_a_null_option : SettingUpALongOptionTestContext 38 | { 39 | Establish context = () => 40 | { 41 | ICommandLineOptionResult nullOption = null; 42 | 43 | var mockOptionFactoryThatReturnsNull = new Mock(); 44 | mockOptionFactoryThatReturnsNull 45 | .Setup(x => x.CreateOption(valid_short_name.ToString(CultureInfo.InvariantCulture), valid_long_name)) 46 | .Returns(nullOption); 47 | 48 | sut.OptionFactory = mockOptionFactoryThatReturnsNull.Object; 49 | }; 50 | 51 | Because of = () => SetupOptionWith(valid_short_name, valid_long_name); 52 | 53 | It should_throw_an_error = () => error.ShouldBeOfType(typeof(InvalidOperationException)); 54 | It should_not_have_setup_an_option = () => sut.Options.ShouldBeEmpty(); 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /FluentCommandLineParser.Tests/FluentCommandLineParser/when_setting_up_a_new_option/and_the_option_factory/throws_an_error.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | // throws_an_error.cs 3 | // Copyright (c) 2013, Simon Williams 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without modification, are permitted provide 7 | // d that the following conditions are met: 8 | // 9 | // Redistributions of source code must retain the above copyright notice, this list of conditions and the 10 | // following disclaimer. 11 | // 12 | // Redistributions in binary form must reproduce the above copyright notice, this list of conditions and 13 | // the following disclaimer in the documentation and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED 16 | // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 17 | // PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 18 | // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 19 | // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 21 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 22 | // POSSIBILITY OF SUCH DAMAGE. 23 | #endregion 24 | 25 | using System.Globalization; 26 | using Fclp.Internals; 27 | using Fclp.Tests.FluentCommandLineParser.TestContext; 28 | using Machine.Specifications; 29 | using Moq; 30 | using It = Machine.Specifications.It; 31 | 32 | namespace Fclp.Tests.FluentCommandLineParser.when_setting_up_a_new_option 33 | { 34 | namespace and_the_option_factory 35 | { 36 | public class throws_an_error : SettingUpALongOptionTestContext 37 | { 38 | Establish context = () => 39 | { 40 | ICommandLineOptionResult nullOption = null; 41 | 42 | var mockOptionFactoryThatReturnsNull = new Mock(); 43 | mockOptionFactoryThatReturnsNull 44 | .Setup(x => x.CreateOption(valid_short_name.ToString(CultureInfo.InvariantCulture), valid_long_name)) 45 | .Throws(); 46 | 47 | sut.OptionFactory = mockOptionFactoryThatReturnsNull.Object; 48 | }; 49 | 50 | Because of = () => SetupOptionWith(valid_short_name, valid_long_name); 51 | 52 | It should_throw_an_error = () => error.ShouldBeOfType(typeof(TestException)); 53 | It should_not_have_setup_an_option = () => sut.Options.ShouldBeEmpty(); 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /FluentCommandLineParser.Tests/FluentCommandLineParser/when_setting_up_a_new_option/with_a_long_name/with_a_long_name.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | // with_a_long_name.cs 3 | // Copyright (c) 2013, Simon Williams 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without modification, are permitted provide 7 | // d that the following conditions are met: 8 | // 9 | // Redistributions of source code must retain the above copyright notice, this list of conditions and the 10 | // following disclaimer. 11 | // 12 | // Redistributions in binary form must reproduce the above copyright notice, this list of conditions and 13 | // the following disclaimer in the documentation and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED 16 | // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 17 | // PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 18 | // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 19 | // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 21 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 22 | // POSSIBILITY OF SUCH DAMAGE. 23 | #endregion 24 | 25 | using System.Globalization; 26 | using Fclp.Tests.FluentCommandLineParser.TestContext; 27 | using Machine.Specifications; 28 | 29 | namespace Fclp.Tests.FluentCommandLineParser 30 | { 31 | namespace when_setting_up_a_new_option 32 | { 33 | public class with_a_long_name : SettingUpALongOptionTestContext 34 | { 35 | Establish context = AutoMockAll; 36 | 37 | Because of = () => SetupOptionWith(valid_short_name, valid_long_name); 38 | 39 | It should_return_a_new_option = () => option.ShouldNotBeNull(); 40 | It should_have_the_given_short_name = () => option.ShortName.ShouldMatch(valid_short_name.ToString(CultureInfo.InvariantCulture)); 41 | It should_have_the_given_long_name = () => option.LongName.ShouldMatch(valid_long_name); 42 | It should_not_be_a_required_option = () => option.IsRequired.ShouldBeFalse(); 43 | It should_have_no_callback = () => option.HasCallback.ShouldBeFalse(); 44 | It should_have_no_additional_args_callback = () => option.HasAdditionalArgumentsCallback.ShouldBeFalse(); 45 | It should_have_no_description = () => option.Description.ShouldBeNull(); 46 | It should_have_no_default_value = () => option.HasDefault.ShouldBeFalse(); 47 | } 48 | } 49 | } -------------------------------------------------------------------------------- /FluentCommandLineParser.Tests/FluentCommandLineParser/when_setting_up_a_new_option/with_a_long_name/with_a_long_name_that_contains_a_colon.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | // with_a_long_name_that_contains_a_colon.cs 3 | // Copyright (c) 2013, Simon Williams 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without modification, are permitted provide 7 | // d that the following conditions are met: 8 | // 9 | // Redistributions of source code must retain the above copyright notice, this list of conditions and the 10 | // following disclaimer. 11 | // 12 | // Redistributions in binary form must reproduce the above copyright notice, this list of conditions and 13 | // the following disclaimer in the documentation and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED 16 | // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 17 | // PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 18 | // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 19 | // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 21 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 22 | // POSSIBILITY OF SUCH DAMAGE. 23 | #endregion 24 | 25 | using Fclp.Tests.FluentCommandLineParser.Behaviour; 26 | using Fclp.Tests.FluentCommandLineParser.TestContext; 27 | using Machine.Specifications; 28 | 29 | namespace Fclp.Tests.FluentCommandLineParser 30 | { 31 | namespace when_setting_up_a_new_option 32 | { 33 | public class with_a_long_name_that_contains_a_colon : SettingUpALongOptionTestContext 34 | { 35 | Establish context = AutoMockAll; 36 | 37 | Because of = () => SetupOptionWith(valid_short_name, invalid_long_name_with_colon); 38 | 39 | Behaves_like a_failed_setup_option; 40 | } 41 | } 42 | } -------------------------------------------------------------------------------- /FluentCommandLineParser.Tests/FluentCommandLineParser/when_setting_up_a_new_option/with_a_long_name/with_a_long_name_that_contains_an_equality_sign.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | // with_a_long_name_that_contains_an_equality_sign.cs 3 | // Copyright (c) 2013, Simon Williams 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without modification, are permitted provide 7 | // d that the following conditions are met: 8 | // 9 | // Redistributions of source code must retain the above copyright notice, this list of conditions and the 10 | // following disclaimer. 11 | // 12 | // Redistributions in binary form must reproduce the above copyright notice, this list of conditions and 13 | // the following disclaimer in the documentation and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED 16 | // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 17 | // PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 18 | // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 19 | // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 21 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 22 | // POSSIBILITY OF SUCH DAMAGE. 23 | #endregion 24 | 25 | using Fclp.Tests.FluentCommandLineParser.Behaviour; 26 | using Fclp.Tests.FluentCommandLineParser.TestContext; 27 | using Machine.Specifications; 28 | 29 | namespace Fclp.Tests.FluentCommandLineParser 30 | { 31 | namespace when_setting_up_a_new_option 32 | { 33 | public class with_a_long_name_that_contains_an_equality_sign : SettingUpALongOptionTestContext 34 | { 35 | Establish context = AutoMockAll; 36 | 37 | Because of = () => SetupOptionWith(valid_short_name, invalid_long_name_with_equality_sign); 38 | 39 | Behaves_like a_failed_setup_option; 40 | } 41 | } 42 | } -------------------------------------------------------------------------------- /FluentCommandLineParser.Tests/FluentCommandLineParser/when_setting_up_a_new_option/with_a_long_name/with_a_long_name_that_contains_whitespace.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | // with_a_long_name_that_contains_whitespace.cs 3 | // Copyright (c) 2013, Simon Williams 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without modification, are permitted provide 7 | // d that the following conditions are met: 8 | // 9 | // Redistributions of source code must retain the above copyright notice, this list of conditions and the 10 | // following disclaimer. 11 | // 12 | // Redistributions in binary form must reproduce the above copyright notice, this list of conditions and 13 | // the following disclaimer in the documentation and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED 16 | // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 17 | // PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 18 | // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 19 | // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 21 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 22 | // POSSIBILITY OF SUCH DAMAGE. 23 | #endregion 24 | 25 | using Fclp.Tests.FluentCommandLineParser.Behaviour; 26 | using Fclp.Tests.FluentCommandLineParser.TestContext; 27 | using Machine.Specifications; 28 | 29 | namespace Fclp.Tests.FluentCommandLineParser 30 | { 31 | namespace when_setting_up_a_new_option 32 | { 33 | public class with_a_long_name_that_contains_whitespace : SettingUpALongOptionTestContext 34 | { 35 | Establish context = AutoMockAll; 36 | 37 | Because of = () => SetupOptionWith(valid_short_name, invalid_long_name_with_spaces); 38 | 39 | Behaves_like a_failed_setup_option; 40 | } 41 | } 42 | } -------------------------------------------------------------------------------- /FluentCommandLineParser.Tests/FluentCommandLineParser/when_setting_up_a_new_option/with_a_long_name/with_a_long_name_that_is_already_used.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | // with_a_long_name_that_is_already_used.cs 3 | // Copyright (c) 2013, Simon Williams 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without modification, are permitted provide 7 | // d that the following conditions are met: 8 | // 9 | // Redistributions of source code must retain the above copyright notice, this list of conditions and the 10 | // following disclaimer. 11 | // 12 | // Redistributions in binary form must reproduce the above copyright notice, this list of conditions and 13 | // the following disclaimer in the documentation and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED 16 | // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 17 | // PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 18 | // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 19 | // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 21 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 22 | // POSSIBILITY OF SUCH DAMAGE. 23 | #endregion 24 | 25 | using Fclp.Internals; 26 | using Fclp.Tests.FluentCommandLineParser.TestContext; 27 | using Machine.Specifications; 28 | using Moq; 29 | using It = Machine.Specifications.It; 30 | 31 | namespace Fclp.Tests.FluentCommandLineParser 32 | { 33 | namespace when_setting_up_a_new_option 34 | { 35 | public class with_a_long_name_that_is_already_used : SettingUpALongOptionTestContext 36 | { 37 | private const string existingLongName = "longName"; 38 | private static ICommandLineOption existingOption; 39 | 40 | Establish context = () => 41 | { 42 | AutoMockAll(); 43 | 44 | var option = new Mock(); 45 | option.SetupGet(x => x.ShortName).Returns("randomshortname"); 46 | option.SetupGet(x => x.LongName).Returns(existingLongName); 47 | existingOption = option.Object; 48 | }; 49 | 50 | Because of = () => 51 | { 52 | sut.Options.Add(existingOption); 53 | SetupOptionWith(valid_short_name, existingLongName); 54 | }; 55 | 56 | It should_throw_an_error = () => error.ShouldBeOfType(typeof(OptionAlreadyExistsException)); 57 | It should_not_have_setup_an_option = () => sut.Options.ShouldContainOnly(existingOption); 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /FluentCommandLineParser.Tests/FluentCommandLineParser/when_setting_up_a_new_option/with_a_long_name/with_a_long_name_that_is_already_used_but_differs_by_case.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | // with_a_long_name_that_is_already_used_but_differs_by_case.cs 3 | // Copyright (c) 2013, Simon Williams 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without modification, are permitted provide 7 | // d that the following conditions are met: 8 | // 9 | // Redistributions of source code must retain the above copyright notice, this list of conditions and the 10 | // following disclaimer. 11 | // 12 | // Redistributions in binary form must reproduce the above copyright notice, this list of conditions and 13 | // the following disclaimer in the documentation and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED 16 | // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 17 | // PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 18 | // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 19 | // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 21 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 22 | // POSSIBILITY OF SUCH DAMAGE. 23 | #endregion 24 | 25 | using Fclp.Internals; 26 | using Fclp.Tests.FluentCommandLineParser.TestContext; 27 | using Machine.Specifications; 28 | using Moq; 29 | using It = Machine.Specifications.It; 30 | 31 | namespace Fclp.Tests.FluentCommandLineParser 32 | { 33 | namespace when_setting_up_a_new_option 34 | { 35 | public class with_a_long_name_that_is_already_used_but_differs_by_case : SettingUpALongOptionTestContext 36 | { 37 | private const string existingLongName = "LONGNAME"; 38 | private static ICommandLineOption existingOption; 39 | 40 | Establish context = () => 41 | { 42 | AutoMockAll(); 43 | 44 | var option = new Mock(); 45 | option.SetupGet(x => x.ShortName).Returns("randomshortname"); 46 | option.SetupGet(x => x.LongName).Returns(existingLongName); 47 | existingOption = option.Object; 48 | }; 49 | 50 | Because of = () => 51 | { 52 | sut.Options.Add(existingOption); 53 | SetupOptionWith(valid_short_name, existingLongName.ToLower()); 54 | }; 55 | 56 | It should_not_throw_an_error = () => error.ShouldBeNull(); 57 | It should_not_have_setup_an_option = () => sut.Options.ShouldContainOnly(new[] { existingOption, option }); 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /FluentCommandLineParser.Tests/FluentCommandLineParser/when_setting_up_a_new_option/with_a_long_name/with_a_long_name_that_is_empty.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | // with_a_long_name_that_is_empty.cs 3 | // Copyright (c) 2013, Simon Williams 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without modification, are permitted provide 7 | // d that the following conditions are met: 8 | // 9 | // Redistributions of source code must retain the above copyright notice, this list of conditions and the 10 | // following disclaimer. 11 | // 12 | // Redistributions in binary form must reproduce the above copyright notice, this list of conditions and 13 | // the following disclaimer in the documentation and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED 16 | // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 17 | // PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 18 | // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 19 | // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 21 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 22 | // POSSIBILITY OF SUCH DAMAGE. 23 | #endregion 24 | 25 | using System.Globalization; 26 | using Fclp.Tests.FluentCommandLineParser.TestContext; 27 | using Machine.Specifications; 28 | 29 | namespace Fclp.Tests.FluentCommandLineParser 30 | { 31 | namespace when_setting_up_a_new_option 32 | { 33 | public class with_a_long_name_that_is_empty : SettingUpALongOptionTestContext 34 | { 35 | Establish context = AutoMockAll; 36 | 37 | Because of = () => SetupOptionWith(valid_short_name, valid_long_name_that_is_empty); 38 | 39 | It should_return_a_new_option = () => option.ShouldNotBeNull(); 40 | It should_have_the_given_short_name = () => option.ShortName.ShouldMatch(valid_short_name.ToString(CultureInfo.InvariantCulture)); 41 | It should_have_the_given_long_name = () => option.LongName.ShouldMatch(valid_long_name_that_is_empty); 42 | It should_not_be_a_required_option = () => option.IsRequired.ShouldBeFalse(); 43 | It should_have_no_callback = () => option.HasCallback.ShouldBeFalse(); 44 | It should_have_no_additional_args_callback = () => option.HasAdditionalArgumentsCallback.ShouldBeFalse(); 45 | It should_have_no_description = () => option.Description.ShouldBeNull(); 46 | It should_have_no_default_value = () => option.HasDefault.ShouldBeFalse(); 47 | } 48 | } 49 | } -------------------------------------------------------------------------------- /FluentCommandLineParser.Tests/FluentCommandLineParser/when_setting_up_a_new_option/with_a_long_name/with_a_long_name_that_is_valid.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | // with_a_long_name_that_is_valid.cs 3 | // Copyright (c) 2013, Simon Williams 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without modification, are permitted provide 7 | // d that the following conditions are met: 8 | // 9 | // Redistributions of source code must retain the above copyright notice, this list of conditions and the 10 | // following disclaimer. 11 | // 12 | // Redistributions in binary form must reproduce the above copyright notice, this list of conditions and 13 | // the following disclaimer in the documentation and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED 16 | // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 17 | // PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 18 | // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 19 | // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 21 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 22 | // POSSIBILITY OF SUCH DAMAGE. 23 | #endregion 24 | 25 | using System.Globalization; 26 | using Fclp.Tests.FluentCommandLineParser.TestContext; 27 | using Machine.Specifications; 28 | 29 | namespace Fclp.Tests.FluentCommandLineParser 30 | { 31 | namespace when_setting_up_a_new_option 32 | { 33 | public class with_a_long_name_that_is_valid : SettingUpALongOptionTestContext 34 | { 35 | Establish context = AutoMockAll; 36 | 37 | Because of = () => SetupOptionWith(valid_short_name, null); 38 | 39 | It should_return_a_new_option = () => option.ShouldNotBeNull(); 40 | It should_have_the_given_short_name = () => option.ShortName.ShouldMatch(valid_short_name.ToString(CultureInfo.InvariantCulture)); 41 | It should_have_the_given_long_name = () => option.LongName.ShouldBeNull(); 42 | It should_not_be_a_required_option = () => option.IsRequired.ShouldBeFalse(); 43 | It should_have_no_callback = () => option.HasCallback.ShouldBeFalse(); 44 | It should_have_no_additional_args_callback = () => option.HasAdditionalArgumentsCallback.ShouldBeFalse(); 45 | It should_have_no_description = () => option.Description.ShouldBeNull(); 46 | It should_have_no_default_value = () => option.HasDefault.ShouldBeFalse(); 47 | } 48 | } 49 | } -------------------------------------------------------------------------------- /FluentCommandLineParser.Tests/FluentCommandLineParser/when_setting_up_a_new_option/with_a_long_name/with_a_long_name_that_is_whitespace.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | // with_a_long_name_that_is_whitespace.cs 3 | // Copyright (c) 2013, Simon Williams 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without modification, are permitted provide 7 | // d that the following conditions are met: 8 | // 9 | // Redistributions of source code must retain the above copyright notice, this list of conditions and the 10 | // following disclaimer. 11 | // 12 | // Redistributions in binary form must reproduce the above copyright notice, this list of conditions and 13 | // the following disclaimer in the documentation and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED 16 | // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 17 | // PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 18 | // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 19 | // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 21 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 22 | // POSSIBILITY OF SUCH DAMAGE. 23 | #endregion 24 | 25 | using Fclp.Tests.FluentCommandLineParser.Behaviour; 26 | using Fclp.Tests.FluentCommandLineParser.TestContext; 27 | using Machine.Specifications; 28 | 29 | namespace Fclp.Tests.FluentCommandLineParser 30 | { 31 | namespace when_setting_up_a_new_option 32 | { 33 | public class with_a_long_name_that_is_whitespace : SettingUpALongOptionTestContext 34 | { 35 | Establish context = AutoMockAll; 36 | 37 | Because of = () => SetupOptionWith(valid_short_name, invalid_long_name_that_is_whitespace); 38 | 39 | Behaves_like a_failed_setup_option; 40 | } 41 | } 42 | } -------------------------------------------------------------------------------- /FluentCommandLineParser.Tests/FluentCommandLineParser/when_setting_up_a_new_option/with_a_short_name/with_a_short_name.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | // with_a_short_name.cs 3 | // Copyright (c) 2013, Simon Williams 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without modification, are permitted provide 7 | // d that the following conditions are met: 8 | // 9 | // Redistributions of source code must retain the above copyright notice, this list of conditions and the 10 | // following disclaimer. 11 | // 12 | // Redistributions in binary form must reproduce the above copyright notice, this list of conditions and 13 | // the following disclaimer in the documentation and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED 16 | // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 17 | // PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 18 | // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 19 | // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 21 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 22 | // POSSIBILITY OF SUCH DAMAGE. 23 | #endregion 24 | 25 | using System.Globalization; 26 | using Fclp.Tests.FluentCommandLineParser.TestContext; 27 | using Machine.Specifications; 28 | 29 | namespace Fclp.Tests.FluentCommandLineParser 30 | { 31 | namespace when_setting_up_a_new_option 32 | { 33 | public class with_a_short_name : SettingUpAShortOptionTestContext 34 | { 35 | Establish context = AutoMockAll; 36 | 37 | Because of = () => SetupOptionWith(valid_short_name); 38 | 39 | It should_return_a_new_option = () => option.ShouldNotBeNull(); 40 | It should_have_the_given_short_name = () => option.ShortName.ShouldMatch(valid_short_name.ToString(CultureInfo.InvariantCulture)); 41 | It should_have_no_long_name = () => option.HasLongName.ShouldBeFalse(); 42 | It should_not_be_a_required_option = () => option.IsRequired.ShouldBeFalse(); 43 | It should_have_no_callback = () => option.HasCallback.ShouldBeFalse(); 44 | It should_have_no_additional_args_callback = () => option.HasAdditionalArgumentsCallback.ShouldBeFalse(); 45 | It should_have_no_description = () => option.Description.ShouldBeNull(); 46 | It should_have_no_default_value = () => option.HasDefault.ShouldBeFalse(); 47 | } 48 | } 49 | } -------------------------------------------------------------------------------- /FluentCommandLineParser.Tests/FluentCommandLineParser/when_setting_up_a_new_option/with_a_short_name/with_a_short_name_that_contains_a_colon.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | // with_a_short_name_that_contains_a_colon.cs 3 | // Copyright (c) 2013, Simon Williams 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without modification, are permitted provide 7 | // d that the following conditions are met: 8 | // 9 | // Redistributions of source code must retain the above copyright notice, this list of conditions and the 10 | // following disclaimer. 11 | // 12 | // Redistributions in binary form must reproduce the above copyright notice, this list of conditions and 13 | // the following disclaimer in the documentation and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED 16 | // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 17 | // PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 18 | // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 19 | // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 21 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 22 | // POSSIBILITY OF SUCH DAMAGE. 23 | #endregion 24 | 25 | using Fclp.Tests.FluentCommandLineParser.Behaviour; 26 | using Fclp.Tests.FluentCommandLineParser.TestContext; 27 | using Machine.Specifications; 28 | 29 | namespace Fclp.Tests.FluentCommandLineParser 30 | { 31 | namespace when_setting_up_a_new_option 32 | { 33 | public class with_a_short_name_that_contains_a_colon : SettingUpAShortOptionTestContext 34 | { 35 | Establish context = AutoMockAll; 36 | 37 | Because of = () => SetupOptionWith(invalid_short_name_with_colon); 38 | 39 | Behaves_like a_failed_setup_option; 40 | } 41 | } 42 | } -------------------------------------------------------------------------------- /FluentCommandLineParser.Tests/FluentCommandLineParser/when_setting_up_a_new_option/with_a_short_name/with_a_short_name_that_contains_an_equality_sign.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | // with_a_short_name_that_contains_an_equality_sign.cs 3 | // Copyright (c) 2013, Simon Williams 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without modification, are permitted provide 7 | // d that the following conditions are met: 8 | // 9 | // Redistributions of source code must retain the above copyright notice, this list of conditions and the 10 | // following disclaimer. 11 | // 12 | // Redistributions in binary form must reproduce the above copyright notice, this list of conditions and 13 | // the following disclaimer in the documentation and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED 16 | // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 17 | // PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 18 | // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 19 | // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 21 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 22 | // POSSIBILITY OF SUCH DAMAGE. 23 | #endregion 24 | 25 | using Fclp.Tests.FluentCommandLineParser.Behaviour; 26 | using Fclp.Tests.FluentCommandLineParser.TestContext; 27 | using Machine.Specifications; 28 | 29 | namespace Fclp.Tests.FluentCommandLineParser 30 | { 31 | namespace when_setting_up_a_new_option 32 | { 33 | public class with_a_short_name_that_contains_an_equality_sign : SettingUpAShortOptionTestContext 34 | { 35 | Establish context = AutoMockAll; 36 | 37 | Because of = () => SetupOptionWith(invalid_short_name_with_equality_sign); 38 | 39 | Behaves_like a_failed_setup_option; 40 | } 41 | } 42 | } -------------------------------------------------------------------------------- /FluentCommandLineParser.Tests/FluentCommandLineParser/when_setting_up_a_new_option/with_a_short_name/with_a_short_name_that_contains_whitespace.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | // with_a_short_name_that_contains_whitespace.cs 3 | // Copyright (c) 2013, Simon Williams 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without modification, are permitted provide 7 | // d that the following conditions are met: 8 | // 9 | // Redistributions of source code must retain the above copyright notice, this list of conditions and the 10 | // following disclaimer. 11 | // 12 | // Redistributions in binary form must reproduce the above copyright notice, this list of conditions and 13 | // the following disclaimer in the documentation and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED 16 | // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 17 | // PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 18 | // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 19 | // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 21 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 22 | // POSSIBILITY OF SUCH DAMAGE. 23 | #endregion 24 | 25 | using Fclp.Tests.FluentCommandLineParser.Behaviour; 26 | using Fclp.Tests.FluentCommandLineParser.TestContext; 27 | using Machine.Specifications; 28 | 29 | namespace Fclp.Tests.FluentCommandLineParser 30 | { 31 | namespace when_setting_up_a_new_option 32 | { 33 | public class with_a_short_name_that_contains_whitespace : SettingUpAShortOptionTestContext 34 | { 35 | Establish context = AutoMockAll; 36 | 37 | Because of = () => SetupOptionWith(invalid_short_name_that_is_whitespace); 38 | 39 | Behaves_like a_failed_setup_option; 40 | } 41 | } 42 | } -------------------------------------------------------------------------------- /FluentCommandLineParser.Tests/FluentCommandLineParser/when_setting_up_a_new_option/with_a_short_name/with_a_short_name_that_is_a_control_char.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | // with_a_short_name_that_is_a_control_char.cs 3 | // Copyright (c) 2013, Simon Williams 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without modification, are permitted provide 7 | // d that the following conditions are met: 8 | // 9 | // Redistributions of source code must retain the above copyright notice, this list of conditions and the 10 | // following disclaimer. 11 | // 12 | // Redistributions in binary form must reproduce the above copyright notice, this list of conditions and 13 | // the following disclaimer in the documentation and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED 16 | // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 17 | // PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 18 | // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 19 | // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 21 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 22 | // POSSIBILITY OF SUCH DAMAGE. 23 | #endregion 24 | 25 | using Fclp.Tests.FluentCommandLineParser.Behaviour; 26 | using Fclp.Tests.FluentCommandLineParser.TestContext; 27 | using Machine.Specifications; 28 | 29 | namespace Fclp.Tests.FluentCommandLineParser 30 | { 31 | namespace when_setting_up_a_new_option 32 | { 33 | public class with_a_short_name_that_is_a_control_char : SettingUpAShortOptionTestContext 34 | { 35 | Establish context = AutoMockAll; 36 | 37 | Because of = () => SetupOptionWith(invalid_short_name_that_is_a_control_char); 38 | 39 | Behaves_like a_failed_setup_option; 40 | } 41 | } 42 | } -------------------------------------------------------------------------------- /FluentCommandLineParser.Tests/FluentCommandLineParser/when_setting_up_a_new_option/with_a_short_name/with_a_short_name_that_is_already_used.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | // with_a_short_name_that_is_already_used.cs 3 | // Copyright (c) 2013, Simon Williams 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without modification, are permitted provide 7 | // d that the following conditions are met: 8 | // 9 | // Redistributions of source code must retain the above copyright notice, this list of conditions and the 10 | // following disclaimer. 11 | // 12 | // Redistributions in binary form must reproduce the above copyright notice, this list of conditions and 13 | // the following disclaimer in the documentation and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED 16 | // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 17 | // PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 18 | // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 19 | // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 21 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 22 | // POSSIBILITY OF SUCH DAMAGE. 23 | #endregion 24 | 25 | using System.Globalization; 26 | using Fclp.Internals; 27 | using Fclp.Tests.FluentCommandLineParser.TestContext; 28 | using Machine.Specifications; 29 | using Moq; 30 | using It = Machine.Specifications.It; 31 | 32 | namespace Fclp.Tests.FluentCommandLineParser 33 | { 34 | namespace when_setting_up_a_new_option 35 | { 36 | public class with_a_short_name_that_is_already_used : SettingUpAShortOptionTestContext 37 | { 38 | private const char existingShortName = 's'; 39 | private static ICommandLineOption existingOption; 40 | 41 | Establish context = () => 42 | { 43 | AutoMockAll(); 44 | 45 | var option = new Mock(); 46 | option.SetupGet(x => x.ShortName).Returns(existingShortName.ToString(CultureInfo.InvariantCulture)); 47 | existingOption = option.Object; 48 | }; 49 | 50 | Because of = () => 51 | { 52 | sut.Options.Add(existingOption); 53 | SetupOptionWith(existingShortName); 54 | }; 55 | 56 | It should_throw_an_error = () => error.ShouldBeOfType(typeof(OptionAlreadyExistsException)); 57 | It should_not_have_setup_an_option = () => sut.Options.ShouldContainOnly(existingOption); 58 | } 59 | } 60 | } -------------------------------------------------------------------------------- /FluentCommandLineParser.Tests/FluentCommandLineParser/when_setting_up_a_new_option/with_a_short_name/with_a_short_name_that_is_already_used_but_differs_by_case.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | // with_a_short_name_that_is_already_used_but_differs_by_case.cs 3 | // Copyright (c) 2013, Simon Williams 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without modification, are permitted provide 7 | // d that the following conditions are met: 8 | // 9 | // Redistributions of source code must retain the above copyright notice, this list of conditions and the 10 | // following disclaimer. 11 | // 12 | // Redistributions in binary form must reproduce the above copyright notice, this list of conditions and 13 | // the following disclaimer in the documentation and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED 16 | // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 17 | // PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 18 | // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 19 | // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 21 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 22 | // POSSIBILITY OF SUCH DAMAGE. 23 | #endregion 24 | 25 | using System.Globalization; 26 | using Fclp.Internals; 27 | using Fclp.Tests.FluentCommandLineParser.TestContext; 28 | using Machine.Specifications; 29 | using Moq; 30 | using It = Machine.Specifications.It; 31 | 32 | namespace Fclp.Tests.FluentCommandLineParser 33 | { 34 | namespace when_setting_up_a_new_option 35 | { 36 | public class with_a_short_name_that_is_already_used_but_differs_by_case : SettingUpAShortOptionTestContext 37 | { 38 | private const char existingShortName = 'S'; 39 | private const char existingShortNameLower = 's'; 40 | private static ICommandLineOption existingOption; 41 | 42 | Establish context = () => 43 | { 44 | AutoMockAll(); 45 | 46 | var option = new Mock(); 47 | option.SetupGet(x => x.ShortName).Returns(existingShortName.ToString(CultureInfo.InvariantCulture)); 48 | existingOption = option.Object; 49 | }; 50 | 51 | Because of = () => 52 | { 53 | sut.Options.Add(existingOption); 54 | SetupOptionWith(existingShortNameLower); 55 | }; 56 | 57 | It should_not_throw_an_error = () => error.ShouldBeNull(); 58 | It should_have_setup_an_option = () => sut.Options.ShouldContainOnly(new[] { existingOption, option }); 59 | } 60 | } 61 | } -------------------------------------------------------------------------------- /FluentCommandLineParser.Tests/FluentCommandLineParser/when_setting_up_a_new_option/with_a_short_name/with_a_short_name_that_is_whitespace.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | // with_a_short_name_that_is_whitespace.cs 3 | // Copyright (c) 2013, Simon Williams 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without modification, are permitted provide 7 | // d that the following conditions are met: 8 | // 9 | // Redistributions of source code must retain the above copyright notice, this list of conditions and the 10 | // following disclaimer. 11 | // 12 | // Redistributions in binary form must reproduce the above copyright notice, this list of conditions and 13 | // the following disclaimer in the documentation and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED 16 | // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 17 | // PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 18 | // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 19 | // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 21 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 22 | // POSSIBILITY OF SUCH DAMAGE. 23 | #endregion 24 | 25 | using Fclp.Tests.FluentCommandLineParser.Behaviour; 26 | using Fclp.Tests.FluentCommandLineParser.TestContext; 27 | using Machine.Specifications; 28 | 29 | namespace Fclp.Tests.FluentCommandLineParser 30 | { 31 | namespace when_setting_up_a_new_option 32 | { 33 | public class with_a_short_name_that_is_whitespace : SettingUpAShortOptionTestContext 34 | { 35 | Establish context = AutoMockAll; 36 | 37 | Because of = () => SetupOptionWith(invalid_short_name_that_is_whitespace); 38 | 39 | Behaves_like a_failed_setup_option; 40 | } 41 | } 42 | } -------------------------------------------------------------------------------- /FluentCommandLineParser.Tests/FluentCommandLineParser/when_using_an_option_factory/that_has_been_set_to_null.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | // that_has_been_set_to_null.cs 3 | // Copyright (c) 2013, Simon Williams 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without modification, are permitted provide 7 | // d that the following conditions are met: 8 | // 9 | // Redistributions of source code must retain the above copyright notice, this list of conditions and the 10 | // following disclaimer. 11 | // 12 | // Redistributions in binary form must reproduce the above copyright notice, this list of conditions and 13 | // the following disclaimer in the documentation and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED 16 | // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 17 | // PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 18 | // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 19 | // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 21 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 22 | // POSSIBILITY OF SUCH DAMAGE. 23 | #endregion 24 | 25 | using Fclp.Internals; 26 | using Fclp.Tests.FluentCommandLineParser.TestContext; 27 | using Machine.Specifications; 28 | 29 | namespace Fclp.Tests.FluentCommandLineParser 30 | { 31 | namespace when_using_an_option_factory 32 | { 33 | public class that_has_been_set_to_null : FluentCommandLineParserTestContext 34 | { 35 | Because of = () => sut.OptionFactory = null; 36 | 37 | It should_be_unable_to_assign_to_null = () => sut.OptionFactory.ShouldNotBeNull(); 38 | It should_use_the_default_one_instead = () => sut.OptionFactory.ShouldBeOfType(typeof(CommandLineOptionFactory)); 39 | } 40 | } 41 | } -------------------------------------------------------------------------------- /FluentCommandLineParser.Tests/FluentCommandLineParser/when_using_an_option_factory/that_is_custom.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | // that_is_custom.cs 3 | // Copyright (c) 2013, Simon Williams 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without modification, are permitted provide 7 | // d that the following conditions are met: 8 | // 9 | // Redistributions of source code must retain the above copyright notice, this list of conditions and the 10 | // following disclaimer. 11 | // 12 | // Redistributions in binary form must reproduce the above copyright notice, this list of conditions and 13 | // the following disclaimer in the documentation and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED 16 | // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 17 | // PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 18 | // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 19 | // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 21 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 22 | // POSSIBILITY OF SUCH DAMAGE. 23 | #endregion 24 | 25 | using Fclp.Internals; 26 | using Fclp.Tests.FluentCommandLineParser.TestContext; 27 | using Machine.Specifications; 28 | using Moq; 29 | using It = Machine.Specifications.It; 30 | 31 | namespace Fclp.Tests.FluentCommandLineParser 32 | { 33 | namespace when_using_an_option_factory 34 | { 35 | public class that_is_custom : SettingUpALongOptionTestContext 36 | { 37 | private const string valid_short_name_custom_factory = "s"; 38 | static ICommandLineOptionFactory customOptionFactory { get { return mockedOptionFactory.Object; } } 39 | static Mock mockedOptionFactory; 40 | 41 | Establish context = () => 42 | { 43 | sut = new Fclp.FluentCommandLineParser(); 44 | mockedOptionFactory = new Mock(); 45 | 46 | mockedOptionFactory 47 | .Setup(x => x.CreateOption(valid_short_name_custom_factory, valid_long_name)) 48 | .Verifiable(); 49 | }; 50 | 51 | Because of = () => 52 | { 53 | sut.OptionFactory = customOptionFactory; 54 | SetupOptionWith(valid_short_name, valid_long_name); 55 | }; 56 | 57 | It should_replace_the_old_factory = 58 | () => sut.OptionFactory.ShouldBeTheSameAs(customOptionFactory); 59 | 60 | It should_be_used_to_create_the_options_objects = 61 | () => mockedOptionFactory.Verify(x => x.CreateOption(valid_short_name_custom_factory, valid_long_name)); 62 | } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /FluentCommandLineParser.Tests/HelperExtensions.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | // HelperExtensions.cs 3 | // Copyright (c) 2013, Simon Williams 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without modification, are permitted provide 7 | // d that the following conditions are met: 8 | // 9 | // Redistributions of source code must retain the above copyright notice, this list of conditions and the 10 | // following disclaimer. 11 | // 12 | // Redistributions in binary form must reproduce the above copyright notice, this list of conditions and 13 | // the following disclaimer in the documentation and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED 16 | // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 17 | // PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 18 | // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 19 | // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 21 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 22 | // POSSIBILITY OF SUCH DAMAGE. 23 | #endregion 24 | 25 | using Fclp.Internals.Parsing; 26 | 27 | namespace FluentCommandLineParser.Tests 28 | { 29 | public static class HelperExtensions 30 | { 31 | /// 32 | /// Returns the specified represented as its interface 33 | /// 34 | public static Fclp.IFluentCommandLineParser AsInterface(this Fclp.FluentCommandLineParser parser) 35 | { 36 | return parser; 37 | } 38 | 39 | /// 40 | /// Returns the specified represented as its interface 41 | /// 42 | public static ICommandLineParserEngine AsInterface(this CommandLineParserEngineMark2 parserEngine) 43 | { 44 | return parserEngine; 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /FluentCommandLineParser.Tests/Integration/BoolInlineDataAttribute.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | // BoolInlineDataAttribute.cs 3 | // Copyright (c) 2013, Simon Williams 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without modification, are permitted provide 7 | // d that the following conditions are met: 8 | // 9 | // Redistributions of source code must retain the above copyright notice, this list of conditions and the 10 | // following disclaimer. 11 | // 12 | // Redistributions in binary form must reproduce the above copyright notice, this list of conditions and 13 | // the following disclaimer in the documentation and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED 16 | // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 17 | // PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 18 | // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 19 | // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 21 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 22 | // POSSIBILITY OF SUCH DAMAGE. 23 | #endregion 24 | 25 | namespace Fclp.Tests.Integration 26 | { 27 | public class BoolInlineDataAttribute : SimpleShortOptionsAreParsedCorrectlyAttribute 28 | { 29 | public BoolInlineDataAttribute(string args, bool expected) 30 | : base(args, expectedBoolean: expected) 31 | { 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /FluentCommandLineParser.Tests/Integration/DoubleInlineDataAttribute.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | // DoubleInlineDataAttribute.cs 3 | // Copyright (c) 2013, Simon Williams 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without modification, are permitted provide 7 | // d that the following conditions are met: 8 | // 9 | // Redistributions of source code must retain the above copyright notice, this list of conditions and the 10 | // following disclaimer. 11 | // 12 | // Redistributions in binary form must reproduce the above copyright notice, this list of conditions and 13 | // the following disclaimer in the documentation and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED 16 | // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 17 | // PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 18 | // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 19 | // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 21 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 22 | // POSSIBILITY OF SUCH DAMAGE. 23 | #endregion 24 | 25 | namespace Fclp.Tests.Integration 26 | { 27 | public class DoubleInlineDataAttribute : SimpleShortOptionsAreParsedCorrectlyAttribute 28 | { 29 | public DoubleInlineDataAttribute(string args, double expected) 30 | : base(args, expectedDouble: expected) 31 | { 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /FluentCommandLineParser.Tests/Integration/EnumInlineDataAttribute.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | // EnumInlineDataAttribute.cs 3 | // Copyright (c) 2014, Simon Williams 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without modification, are permitted provide 7 | // d that the following conditions are met: 8 | // 9 | // Redistributions of source code must retain the above copyright notice, this list of conditions and the 10 | // following disclaimer. 11 | // 12 | // Redistributions in binary form must reproduce the above copyright notice, this list of conditions and 13 | // the following disclaimer in the documentation and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED 16 | // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 17 | // PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 18 | // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 19 | // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 21 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 22 | // POSSIBILITY OF SUCH DAMAGE. 23 | #endregion 24 | 25 | using Fclp.Tests.FluentCommandLineParser; 26 | 27 | namespace Fclp.Tests.Integration 28 | { 29 | public class EnumInlineDataAttribute : SimpleShortOptionsAreParsedCorrectlyAttribute 30 | { 31 | public EnumInlineDataAttribute(string args, TestEnum expected) 32 | : base(args, expectedEnum: expected) 33 | { 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /FluentCommandLineParser.Tests/Integration/Int32EnumInlineDataAttribute.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | // Int32EnumInlineDataAttribute.cs 3 | // Copyright (c) 2014, Simon Williams 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without modification, are permitted provide 7 | // d that the following conditions are met: 8 | // 9 | // Redistributions of source code must retain the above copyright notice, this list of conditions and the 10 | // following disclaimer. 11 | // 12 | // Redistributions in binary form must reproduce the above copyright notice, this list of conditions and 13 | // the following disclaimer in the documentation and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED 16 | // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 17 | // PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 18 | // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 19 | // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 21 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 22 | // POSSIBILITY OF SUCH DAMAGE. 23 | #endregion 24 | 25 | using Fclp.Tests.FluentCommandLineParser; 26 | 27 | namespace Fclp.Tests.Integration 28 | { 29 | public class Int32EnumInlineDataAttribute : SimpleShortOptionsAreParsedCorrectlyAttribute 30 | { 31 | public Int32EnumInlineDataAttribute(string args, TestEnum expected) 32 | : base(args, expectedEnum: expected) 33 | { 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /FluentCommandLineParser.Tests/Integration/Int32InlineDataAttribute.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | // Int32InlineDataAttribute.cs 3 | // Copyright (c) 2013, Simon Williams 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without modification, are permitted provide 7 | // d that the following conditions are met: 8 | // 9 | // Redistributions of source code must retain the above copyright notice, this list of conditions and the 10 | // following disclaimer. 11 | // 12 | // Redistributions in binary form must reproduce the above copyright notice, this list of conditions and 13 | // the following disclaimer in the documentation and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED 16 | // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 17 | // PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 18 | // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 19 | // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 21 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 22 | // POSSIBILITY OF SUCH DAMAGE. 23 | #endregion 24 | 25 | namespace Fclp.Tests.Integration 26 | { 27 | public class Int32InlineDataAttribute : SimpleShortOptionsAreParsedCorrectlyAttribute 28 | { 29 | public Int32InlineDataAttribute(string args, int expected) 30 | : base(args, expectedInt32: expected) 31 | { 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /FluentCommandLineParser.Tests/Integration/Int64InlineDataAttribute.cs: -------------------------------------------------------------------------------- 1 | namespace Fclp.Tests.Integration 2 | { 3 | public class Int64InlineDataAttribute : SimpleShortOptionsAreParsedCorrectlyAttribute 4 | { 5 | public Int64InlineDataAttribute(string args, long expected) 6 | : base(args, expectedInt64: expected) 7 | { 8 | } 9 | } 10 | } -------------------------------------------------------------------------------- /FluentCommandLineParser.Tests/Integration/Lists/ArgumentInlineDataAttribute.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | // ArgumentInlineDataAttribute.cs 3 | // Copyright (c) 2013, Simon Williams 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without modification, are permitted provide 7 | // d that the following conditions are met: 8 | // 9 | // Redistributions of source code must retain the above copyright notice, this list of conditions and the 10 | // following disclaimer. 11 | // 12 | // Redistributions in binary form must reproduce the above copyright notice, this list of conditions and 13 | // the following disclaimer in the documentation and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED 16 | // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 17 | // PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 18 | // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 19 | // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 21 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 22 | // POSSIBILITY OF SUCH DAMAGE. 23 | #endregion 24 | 25 | using Xunit.Extensions; 26 | 27 | namespace Fclp.Tests.Integration 28 | { 29 | public class ArgumentInlineDataAttribute : InlineDataAttribute 30 | { 31 | public ArgumentInlineDataAttribute(string args, object obj) 32 | : base(args, obj) 33 | { 34 | } 35 | 36 | public ArgumentInlineDataAttribute(string args, params string[] values) 37 | : base(args, values) 38 | { 39 | 40 | } 41 | } 42 | } -------------------------------------------------------------------------------- /FluentCommandLineParser.Tests/Integration/Lists/BoolListInlineDataAttribute.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | // BoolListInlineDataAttribute.cs 3 | // Copyright (c) 2013, Simon Williams 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without modification, are permitted provide 7 | // d that the following conditions are met: 8 | // 9 | // Redistributions of source code must retain the above copyright notice, this list of conditions and the 10 | // following disclaimer. 11 | // 12 | // Redistributions in binary form must reproduce the above copyright notice, this list of conditions and 13 | // the following disclaimer in the documentation and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED 16 | // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 17 | // PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 18 | // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 19 | // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 21 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 22 | // POSSIBILITY OF SUCH DAMAGE. 23 | #endregion 24 | namespace Fclp.Tests.Integration 25 | { 26 | public class BoolListInlineDataAttribute : ArgumentInlineDataAttribute 27 | { 28 | public BoolListInlineDataAttribute(string args, params bool[] listItems) 29 | : base(args, listItems) 30 | { 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /FluentCommandLineParser.Tests/Integration/Lists/DoubleListInlineDataAttribute.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | // DoubleListInlineDataAttribute.cs 3 | // Copyright (c) 2013, Simon Williams 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without modification, are permitted provide 7 | // d that the following conditions are met: 8 | // 9 | // Redistributions of source code must retain the above copyright notice, this list of conditions and the 10 | // following disclaimer. 11 | // 12 | // Redistributions in binary form must reproduce the above copyright notice, this list of conditions and 13 | // the following disclaimer in the documentation and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED 16 | // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 17 | // PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 18 | // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 19 | // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 21 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 22 | // POSSIBILITY OF SUCH DAMAGE. 23 | #endregion 24 | namespace Fclp.Tests.Integration 25 | { 26 | public class DoubleListInlineDataAttribute : ArgumentInlineDataAttribute 27 | { 28 | public DoubleListInlineDataAttribute(string args, params double[] listItems) 29 | : base(args, listItems) 30 | { 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /FluentCommandLineParser.Tests/Integration/Lists/EnumFlagListInlineDataAttribute .cs: -------------------------------------------------------------------------------- 1 | #region License 2 | // EnumListInlineDataAttribute.cs 3 | // Copyright (c) 2014, Simon Williams 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without modification, are permitted provide 7 | // d that the following conditions are met: 8 | // 9 | // Redistributions of source code must retain the above copyright notice, this list of conditions and the 10 | // following disclaimer. 11 | // 12 | // Redistributions in binary form must reproduce the above copyright notice, this list of conditions and 13 | // the following disclaimer in the documentation and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED 16 | // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 17 | // PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 18 | // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 19 | // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 21 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 22 | // POSSIBILITY OF SUCH DAMAGE. 23 | #endregion 24 | 25 | using Fclp.Tests.FluentCommandLineParser; 26 | 27 | namespace Fclp.Tests.Integration 28 | { 29 | public class EnumFlagListInlineDataAttribute : ArgumentInlineDataAttribute 30 | { 31 | public EnumFlagListInlineDataAttribute(string args, params TestEnumFlag[] listItems) 32 | : base(args, listItems) 33 | { 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /FluentCommandLineParser.Tests/Integration/Lists/EnumListInlineDataAttribute.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | // EnumListInlineDataAttribute.cs 3 | // Copyright (c) 2014, Simon Williams 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without modification, are permitted provide 7 | // d that the following conditions are met: 8 | // 9 | // Redistributions of source code must retain the above copyright notice, this list of conditions and the 10 | // following disclaimer. 11 | // 12 | // Redistributions in binary form must reproduce the above copyright notice, this list of conditions and 13 | // the following disclaimer in the documentation and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED 16 | // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 17 | // PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 18 | // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 19 | // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 21 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 22 | // POSSIBILITY OF SUCH DAMAGE. 23 | #endregion 24 | 25 | using Fclp.Tests.FluentCommandLineParser; 26 | 27 | namespace Fclp.Tests.Integration 28 | { 29 | public class EnumListInlineDataAttribute : ArgumentInlineDataAttribute 30 | { 31 | public EnumListInlineDataAttribute(string args, params TestEnum[] listItems) 32 | : base(args, listItems) 33 | { 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /FluentCommandLineParser.Tests/Integration/Lists/Int32ListInlineDataAttribute.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | // Int32ListInlineDataAttribute.cs 3 | // Copyright (c) 2013, Simon Williams 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without modification, are permitted provide 7 | // d that the following conditions are met: 8 | // 9 | // Redistributions of source code must retain the above copyright notice, this list of conditions and the 10 | // following disclaimer. 11 | // 12 | // Redistributions in binary form must reproduce the above copyright notice, this list of conditions and 13 | // the following disclaimer in the documentation and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED 16 | // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 17 | // PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 18 | // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 19 | // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 21 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 22 | // POSSIBILITY OF SUCH DAMAGE. 23 | #endregion 24 | namespace Fclp.Tests.Integration 25 | { 26 | public class Int32ListInlineDataAttribute : ArgumentInlineDataAttribute 27 | { 28 | public Int32ListInlineDataAttribute(string args, params int[] listItems) 29 | : base(args, listItems) 30 | { 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /FluentCommandLineParser.Tests/Integration/Lists/Int64ListInlineDataAttribute.cs: -------------------------------------------------------------------------------- 1 | namespace Fclp.Tests.Integration 2 | { 3 | public class Int64ListInlineDataAttribute : ArgumentInlineDataAttribute 4 | { 5 | public Int64ListInlineDataAttribute(string args, params long[] listItems) 6 | : base(args, listItems) 7 | { 8 | } 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /FluentCommandLineParser.Tests/Integration/Lists/StringListInlineDataAttribute.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | // StringListInlineDataAttribute.cs 3 | // Copyright (c) 2013, Simon Williams 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without modification, are permitted provide 7 | // d that the following conditions are met: 8 | // 9 | // Redistributions of source code must retain the above copyright notice, this list of conditions and the 10 | // following disclaimer. 11 | // 12 | // Redistributions in binary form must reproduce the above copyright notice, this list of conditions and 13 | // the following disclaimer in the documentation and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED 16 | // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 17 | // PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 18 | // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 19 | // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 21 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 22 | // POSSIBILITY OF SUCH DAMAGE. 23 | #endregion 24 | namespace Fclp.Tests.Integration 25 | { 26 | public class StringListInlineDataAttribute : ArgumentInlineDataAttribute 27 | { 28 | public StringListInlineDataAttribute(string args, params string[] listItems) 29 | : base(args, listItems) 30 | { 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /FluentCommandLineParser.Tests/Integration/NCrunchExcelDataAttribute.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | // NCrunchExcelDataAttribute.cs 3 | // Copyright (c) 2013, Simon Williams 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without modification, are permitted provide 7 | // d that the following conditions are met: 8 | // 9 | // Redistributions of source code must retain the above copyright notice, this list of conditions and the 10 | // following disclaimer. 11 | // 12 | // Redistributions in binary form must reproduce the above copyright notice, this list of conditions and 13 | // the following disclaimer in the documentation and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED 16 | // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 17 | // PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 18 | // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 19 | // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 21 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 22 | // POSSIBILITY OF SUCH DAMAGE. 23 | #endregion 24 | 25 | using System.IO; 26 | using Machine.Specifications; 27 | using Xunit.Extensions; 28 | 29 | namespace Fclp.Tests.Integration 30 | { 31 | public class NCrunchExcelDataAttribute : ExcelDataAttribute 32 | { 33 | public NCrunchExcelDataAttribute(string filename, string selectStatement) 34 | : base(GetPathFromContext(filename), selectStatement) 35 | { 36 | } 37 | 38 | private static string GetPathFromContext(string filename) 39 | { 40 | string newFilePath = filename; 41 | #if NCRUNCH 42 | newFilePath = (Directory.GetCurrentDirectory() + @"/" + filename); 43 | #endif 44 | File.Exists(newFilePath).ShouldBeTrue(); 45 | 46 | return newFilePath; 47 | } 48 | } 49 | } -------------------------------------------------------------------------------- /FluentCommandLineParser.Tests/Integration/SimpleShortOptionsAreParsedCorrectlyAttribute.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | // SimpleShortOptionsAreParsedCorrectlyAttribute.cs 3 | // Copyright (c) 2014, Simon Williams 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without modification, are permitted provide 7 | // d that the following conditions are met: 8 | // 9 | // Redistributions of source code must retain the above copyright notice, this list of conditions and the 10 | // following disclaimer. 11 | // 12 | // Redistributions in binary form must reproduce the above copyright notice, this list of conditions and 13 | // the following disclaimer in the documentation and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED 16 | // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 17 | // PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 18 | // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 19 | // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 21 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 22 | // POSSIBILITY OF SUCH DAMAGE. 23 | #endregion 24 | 25 | using Fclp.Tests.FluentCommandLineParser; 26 | using Xunit.Extensions; 27 | 28 | namespace Fclp.Tests.Integration 29 | { 30 | public class SimpleShortOptionsAreParsedCorrectlyAttribute : InlineDataAttribute 31 | { 32 | public SimpleShortOptionsAreParsedCorrectlyAttribute( 33 | string arguments, 34 | bool? expectedBoolean = null, 35 | string expectedString = null, 36 | int? expectedInt32 = null, 37 | long? expectedInt64 = null, 38 | double? expectedDouble = null, 39 | TestEnum? expectedEnum = null) 40 | : base(arguments, expectedBoolean, expectedString, expectedInt32, expectedInt64, expectedDouble, expectedEnum) 41 | { 42 | 43 | } 44 | } 45 | } -------------------------------------------------------------------------------- /FluentCommandLineParser.Tests/Integration/StringInlineDataAttribute.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | // StringInlineDataAttribute.cs 3 | // Copyright (c) 2013, Simon Williams 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without modification, are permitted provide 7 | // d that the following conditions are met: 8 | // 9 | // Redistributions of source code must retain the above copyright notice, this list of conditions and the 10 | // following disclaimer. 11 | // 12 | // Redistributions in binary form must reproduce the above copyright notice, this list of conditions and 13 | // the following disclaimer in the documentation and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED 16 | // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 17 | // PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 18 | // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 19 | // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 21 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 22 | // POSSIBILITY OF SUCH DAMAGE. 23 | #endregion 24 | 25 | namespace Fclp.Tests.Integration 26 | { 27 | public class StringInlineDataAttribute : SimpleShortOptionsAreParsedCorrectlyAttribute 28 | { 29 | public StringInlineDataAttribute(string args, string expected) 30 | : base(string.Format(args, string.Format(@"""{0}""", expected)), expectedString: expected) 31 | { 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /FluentCommandLineParser.Tests/Internals/CommandLineParserEngine/Behaviour/NoResultsBehaviour.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | // NoResultsBehaviour.cs 3 | // Copyright (c) 2013, Simon Williams 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without modification, are permitted provide 7 | // d that the following conditions are met: 8 | // 9 | // Redistributions of source code must retain the above copyright notice, this list of conditions and the 10 | // following disclaimer. 11 | // 12 | // Redistributions in binary form must reproduce the above copyright notice, this list of conditions and 13 | // the following disclaimer in the documentation and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED 16 | // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 17 | // PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 18 | // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 19 | // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 21 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 22 | // POSSIBILITY OF SUCH DAMAGE. 23 | #endregion 24 | 25 | using System; 26 | using System.Collections.Generic; 27 | using Fclp.Internals.Parsing; 28 | using Machine.Specifications; 29 | 30 | namespace Fclp.Tests 31 | { 32 | namespace CommandLineParserEngine 33 | { 34 | [Behaviors] 35 | public class NoResultsBehaviour 36 | { 37 | protected static Exception error; 38 | protected static IEnumerable results; 39 | 40 | It should_not_error = () => error.ShouldBeNull(); 41 | It should_return_no_found_values = () => results.ShouldBeEmpty(); 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /FluentCommandLineParser.Tests/Internals/CommandLineParserEngine/TestContext/CommandLineParserEngineTestContext.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | // CommandLineParserEngineTestContext.cs 3 | // Copyright (c) 2013, Simon Williams 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without modification, are permitted provide 7 | // d that the following conditions are met: 8 | // 9 | // Redistributions of source code must retain the above copyright notice, this list of conditions and the 10 | // following disclaimer. 11 | // 12 | // Redistributions in binary form must reproduce the above copyright notice, this list of conditions and 13 | // the following disclaimer in the documentation and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED 16 | // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 17 | // PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 18 | // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 19 | // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 21 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 22 | // POSSIBILITY OF SUCH DAMAGE. 23 | #endregion 24 | 25 | using System.Collections.Generic; 26 | using System.Linq; 27 | using Fclp.Internals; 28 | using Fclp.Internals.Parsing; 29 | using Machine.Specifications; 30 | 31 | namespace Fclp.Tests 32 | { 33 | namespace CommandLineParserEngine 34 | { 35 | [Subject(typeof(CommandLineParserEngineMark2), "CommandLineParserEngine")] 36 | public abstract class CommandLineParserEngineTestContext : TestContext 37 | { 38 | protected static SpecialCharacters specialCharacters = new SpecialCharacters(); 39 | protected static IEnumerable results; 40 | protected static string[] args; 41 | 42 | Establish context = () => sut = new CommandLineParserEngineMark2(specialCharacters); 43 | 44 | protected static void RunParserWith(string[] args) 45 | { 46 | CatchAnyError(() => results = sut.Parse(args, false).ParsedOptions.ToList()); 47 | } 48 | } 49 | } 50 | } -------------------------------------------------------------------------------- /FluentCommandLineParser.Tests/Internals/CommandLineParserEngine/when_a_new_instance_is_created.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | // when_a_new_instance_is_created.cs 3 | // Copyright (c) 2013, Simon Williams 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without modification, are permitted provide 7 | // d that the following conditions are met: 8 | // 9 | // Redistributions of source code must retain the above copyright notice, this list of conditions and the 10 | // following disclaimer. 11 | // 12 | // Redistributions in binary form must reproduce the above copyright notice, this list of conditions and 13 | // the following disclaimer in the documentation and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED 16 | // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 17 | // PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 18 | // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 19 | // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 21 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 22 | // POSSIBILITY OF SUCH DAMAGE. 23 | #endregion 24 | 25 | using Machine.Specifications; 26 | 27 | namespace Fclp.Tests 28 | { 29 | namespace CommandLineParserEngine 30 | { 31 | public class when_a_new_instance_is_created : CommandLineParserEngineTestContext 32 | { 33 | It should_construct = () => sut.ShouldNotBeNull(); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /FluentCommandLineParser.Tests/Internals/CommandLineParserEngine/when_arg_contains_key_and_value_assignment_but_no_value.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | // when_arg_contains_key_and_value_assignment_but_no_value.cs 3 | // Copyright (c) 2013, Simon Williams 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without modification, are permitted provide 7 | // d that the following conditions are met: 8 | // 9 | // Redistributions of source code must retain the above copyright notice, this list of conditions and the 10 | // following disclaimer. 11 | // 12 | // Redistributions in binary form must reproduce the above copyright notice, this list of conditions and 13 | // the following disclaimer in the documentation and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED 16 | // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 17 | // PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 18 | // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 19 | // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 21 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 22 | // POSSIBILITY OF SUCH DAMAGE. 23 | #endregion 24 | 25 | using Fclp.Internals.Parsing; 26 | using Fclp.Tests.CommandLineParserEngine; 27 | using Machine.Specifications; 28 | 29 | namespace Fclp.Tests.Internals.CommandLineParserEngine 30 | { 31 | class when_arg_contains_key_and_value_assignment_but_no_value : CommandLineParserEngineTestContext 32 | { 33 | static ParsedOption key = new ParsedOption("key", null); 34 | static ParsedOption key2 = new ParsedOption("key2", "key2value"); 35 | 36 | Establish context = () => args = new[] { "/key=", "/key2", "key2value" }; 37 | Because of = () => RunParserWith(args); 38 | It should_return_key_with_null_value = () => results.ShouldContain(key); 39 | It should_return_key2_with_expected_value = () => results.ShouldContain(key2); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /FluentCommandLineParser.Tests/Internals/CommandLineParserEngine/when_args_contains_a_boolean_option_that_ends_with_no_sign.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | // when_args_contains_a_boolean_option_that_ends_with_no_sign.cs 3 | // Copyright (c) 2013, Simon Williams 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without modification, are permitted provide 7 | // d that the following conditions are met: 8 | // 9 | // Redistributions of source code must retain the above copyright notice, this list of conditions and the 10 | // following disclaimer. 11 | // 12 | // Redistributions in binary form must reproduce the above copyright notice, this list of conditions and 13 | // the following disclaimer in the documentation and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED 16 | // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 17 | // PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 18 | // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 19 | // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 21 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 22 | // POSSIBILITY OF SUCH DAMAGE. 23 | #endregion 24 | 25 | using Fclp.Internals.Parsing; 26 | using Machine.Specifications; 27 | 28 | namespace Fclp.Tests 29 | { 30 | namespace CommandLineParserEngine 31 | { 32 | class when_args_contains_a_boolean_option_that_ends_with_no_sign : CommandLineParserEngineTestContext 33 | { 34 | static ParsedOption expected = new ParsedOption("key", null); 35 | 36 | Establish context = () => args = new[] { "/key" }; 37 | 38 | Because of = () => RunParserWith(args); 39 | 40 | It should_return_key_with_null_value = () => results.ShouldContainOnly(expected); 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /FluentCommandLineParser.Tests/Internals/CommandLineParserEngine/when_specified_args_are_empty.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | // when_specified_args_are_empty.cs 3 | // Copyright (c) 2013, Simon Williams 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without modification, are permitted provide 7 | // d that the following conditions are met: 8 | // 9 | // Redistributions of source code must retain the above copyright notice, this list of conditions and the 10 | // following disclaimer. 11 | // 12 | // Redistributions in binary form must reproduce the above copyright notice, this list of conditions and 13 | // the following disclaimer in the documentation and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED 16 | // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 17 | // PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 18 | // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 19 | // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 21 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 22 | // POSSIBILITY OF SUCH DAMAGE. 23 | #endregion 24 | 25 | using Machine.Specifications; 26 | 27 | namespace Fclp.Tests 28 | { 29 | namespace CommandLineParserEngine 30 | { 31 | public class when_specified_args_are_empty : CommandLineParserEngineTestContext 32 | { 33 | Establish context = () => args = new string[0]; 34 | 35 | Because of = () => RunParserWith(args); 36 | 37 | Behaves_like there_are_no_keys_found; 38 | } 39 | } 40 | } -------------------------------------------------------------------------------- /FluentCommandLineParser.Tests/Internals/CommandLineParserEngine/when_specified_args_are_null.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | // when_specified_args_are_null.cs 3 | // Copyright (c) 2013, Simon Williams 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without modification, are permitted provide 7 | // d that the following conditions are met: 8 | // 9 | // Redistributions of source code must retain the above copyright notice, this list of conditions and the 10 | // following disclaimer. 11 | // 12 | // Redistributions in binary form must reproduce the above copyright notice, this list of conditions and 13 | // the following disclaimer in the documentation and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED 16 | // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 17 | // PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 18 | // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 19 | // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 21 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 22 | // POSSIBILITY OF SUCH DAMAGE. 23 | #endregion 24 | 25 | using Machine.Specifications; 26 | 27 | namespace Fclp.Tests 28 | { 29 | namespace CommandLineParserEngine 30 | { 31 | public class when_specified_args_are_null : CommandLineParserEngineTestContext 32 | { 33 | Establish context = () => args = null; 34 | 35 | Because of = () => RunParserWith(args); 36 | 37 | Behaves_like there_are_no_keys_found; 38 | } 39 | } 40 | } -------------------------------------------------------------------------------- /FluentCommandLineParser.Tests/Internals/Errors/ExpectedOptionNotFoundParseErrorTests.cs: -------------------------------------------------------------------------------- 1 | #region license 2 | // 3 | // Copyright (c) 2012, Siy Williams (siy.williams@gmail.com) 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without modification, are permitted 7 | // provided that the following conditions are met: 8 | // 9 | // Redistributions of source code must retain the above copyright notice, this list of conditions 10 | // and the following disclaimer. Redistributions in binary form must reproduce the above copyright 11 | // notice, this list of conditions and the following disclaimer in the documentation and/or other 12 | // materials provided with the distribution. Neither the name of the organization nor the names 13 | // of its contributors may be used to endorse or promote products derived from this software without 14 | // specific prior written permission. 15 | // 16 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR 17 | // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY 18 | // AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 19 | // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20 | // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 22 | // IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 23 | // OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | // 25 | #endregion 26 | 27 | using System; 28 | using NUnit.Framework; 29 | using Moq; 30 | 31 | namespace FluentCommandLineParser.Internals.Errors 32 | { 33 | [TestFixture] 34 | public class ExpectedOptionNotFoundParseErrorTests 35 | { 36 | [Test] 37 | public void Ensure_Can_Be_Constructed() 38 | { 39 | var cmdOption = Mock.Of(); 40 | var snfError = new ExpectedOptionNotFoundParseError(cmdOption); 41 | Assert.AreSame(cmdOption, snfError.Option); 42 | } 43 | 44 | [Test] 45 | [ExpectedException(typeof(ArgumentNullException))] 46 | public void Ensure_Cannot_Specify_Null_option() 47 | { 48 | new ExpectedOptionNotFoundParseError(null); 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /FluentCommandLineParser.Tests/Internals/UsefulExtensionTests.cs: -------------------------------------------------------------------------------- 1 | using Fclp.Internals.Extensions; 2 | using NUnit.Framework; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace Fclp.Tests.Internals 10 | { 11 | /// 12 | /// option value that has double quote at the end 13 | /// 14 | [TestFixture] 15 | public class when_there_is_qoute_in_the_end 16 | { 17 | [Test] 18 | public void parser() // not sure that it should be here 19 | { 20 | var args = new[] { "--param", "something \"4\"" }; 21 | 22 | var sut = new Fclp.FluentCommandLineParser(); 23 | sut.Setup(_ => _.Param).As('p', "param"); 24 | var res = sut.Parse(args); 25 | 26 | Assert.AreEqual("something \"4\"", sut.Object.Param); 27 | } 28 | 29 | [Test] 30 | public void RemoveAnyWrappingDoubleQuotes() 31 | { 32 | var str = "something \"4\""; 33 | str = str.WrapInDoubleQuotes(); 34 | str = str.RemoveAnyWrappingDoubleQuotes(); 35 | Assert.AreEqual("something \"4\"", str); 36 | } 37 | } 38 | 39 | public class Config 40 | { 41 | public string Param { get; set; } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /FluentCommandLineParser.Tests/Mspec/CommandLineParserEngine/Behaviour/NoResultsBehaviour.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using Machine.Specifications; 4 | 5 | namespace FluentCommandLineParser.Tests 6 | { 7 | namespace CommandLineParserEngineTests 8 | { 9 | [Behaviors] 10 | public class NoResultsBehaviour 11 | { 12 | protected static Exception error; 13 | protected static IEnumerable> results; 14 | 15 | It should_not_error = () => error.ShouldBeNull(); 16 | It should_return_no_found_values = () => results.ShouldBeEmpty(); 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /FluentCommandLineParser.Tests/Mspec/CommandLineParserEngine/TestContext/CommandLineParserEngineTestContext.cs: -------------------------------------------------------------------------------- 1 | #region license 2 | // 3 | // Copyright (c) 2012, Siy Williams (siy.williams@gmail.com) 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without modification, are permitted 7 | // provided that the following conditions are met: 8 | // 9 | // Redistributions of source code must retain the above copyright notice, this list of conditions 10 | // and the following disclaimer. Redistributions in binary form must reproduce the above copyright 11 | // notice, this list of conditions and the following disclaimer in the documentation and/or other 12 | // materials provided with the distribution. Neither the name of the organization nor the names 13 | // of its contributors may be used to endorse or promote products derived from this software without 14 | // specific prior written permission. 15 | // 16 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR 17 | // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY 18 | // AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 19 | // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20 | // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 21 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 22 | // IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 23 | // OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | // 25 | #endregion 26 | 27 | using System; 28 | using System.Collections.Generic; 29 | using System.Linq; 30 | using FluentCommandLineParser.Internals; 31 | using Machine.Specifications; 32 | 33 | namespace FluentCommandLineParser.Tests 34 | { 35 | namespace CommandLineParserEngineTests 36 | { 37 | [Subject(typeof(CommandLineParserEngine), "CommandLineParserEngine")] 38 | public abstract class CommandLineParserEngineTestContext 39 | { 40 | protected static Exception error; 41 | protected static IEnumerable> results; 42 | protected static string[] args; 43 | protected static CommandLineParserEngine sut; 44 | 45 | Establish context = () => sut = new CommandLineParserEngine(); 46 | 47 | protected static void RunParserWith(string[] args) 48 | { 49 | error = Catch.Exception(() => results = sut.Parse(args).ToList()); 50 | } 51 | } 52 | } 53 | } -------------------------------------------------------------------------------- /FluentCommandLineParser.Tests/Mspec/Subjects.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | // Subjects.cs 3 | // Copyright (c) 2013, Simon Williams 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without modification, are permitted provide 7 | // d that the following conditions are met: 8 | // 9 | // Redistributions of source code must retain the above copyright notice, this list of conditions and the 10 | // following disclaimer. 11 | // 12 | // Redistributions in binary form must reproduce the above copyright notice, this list of conditions and 13 | // the following disclaimer in the documentation and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED 16 | // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 17 | // PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 18 | // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 19 | // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 21 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 22 | // POSSIBILITY OF SUCH DAMAGE. 23 | #endregion 24 | namespace Fclp.Tests 25 | { 26 | public static class Subjects 27 | { 28 | public const string setup_new_option = "Setting up a new Option"; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /FluentCommandLineParser.Tests/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | // AssemblyInfo.cs 3 | // Copyright (c) 2013, Simon Williams 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without modification, are permitted provide 7 | // d that the following conditions are met: 8 | // 9 | // Redistributions of source code must retain the above copyright notice, this list of conditions and the 10 | // following disclaimer. 11 | // 12 | // Redistributions in binary form must reproduce the above copyright notice, this list of conditions and 13 | // the following disclaimer in the documentation and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED 16 | // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 17 | // PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 18 | // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 19 | // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 21 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 22 | // POSSIBILITY OF SUCH DAMAGE. 23 | #endregion 24 | 25 | using System; 26 | using System.Reflection; 27 | using System.Runtime.InteropServices; 28 | 29 | // General Information about an assembly is controlled through the following 30 | // set of attributes. Change these attribute values to modify the information 31 | // associated with an assembly. 32 | [assembly: AssemblyTitle("FluentCommandLineParser.Tests")] 33 | [assembly: AssemblyDescription("")] 34 | [assembly: AssemblyConfiguration("")] 35 | [assembly: AssemblyCompany("")] 36 | [assembly: AssemblyProduct("FluentCommandLineParser")] 37 | [assembly: AssemblyCopyright("Copyright © Simon Williams 2012 - 2013")] 38 | [assembly: AssemblyTrademark("")] 39 | [assembly: AssemblyCulture("")] 40 | [assembly: CLSCompliant(true)] 41 | 42 | // Setting ComVisible to false makes the types in this assembly not visible 43 | // to COM components. If you need to access a type in this assembly from 44 | // COM, set the ComVisible attribute to true on that type. 45 | [assembly: ComVisible(false)] 46 | 47 | // The following GUID is for the ID of the typelib if this project is exposed to COM 48 | [assembly: Guid("9dc00720-9d8b-4315-974b-395feb71e827")] 49 | 50 | // !! DO NOT CHANGE - VERSIONS ARE HANDLED AUTOMATICALLY FROM THE CONTINUOUS INTEGRATION SERVER!! 51 | [assembly: AssemblyVersion("0.0.0.0")] 52 | [assembly: AssemblyFileVersion("0.0.0.0")] 53 | 54 | -------------------------------------------------------------------------------- /FluentCommandLineParser.Tests/TestApplicationArgs.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | // TestApplicationArgs.cs 3 | // Copyright (c) 2013, Simon Williams 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without modification, are permitted provide 7 | // d that the following conditions are met: 8 | // 9 | // Redistributions of source code must retain the above copyright notice, this list of conditions and the 10 | // following disclaimer. 11 | // 12 | // Redistributions in binary form must reproduce the above copyright notice, this list of conditions and 13 | // the following disclaimer in the documentation and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED 16 | // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 17 | // PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 18 | // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 19 | // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 21 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 22 | // POSSIBILITY OF SUCH DAMAGE. 23 | #endregion 24 | 25 | using Fclp.Tests.FluentCommandLineParser; 26 | 27 | namespace Fclp.Tests 28 | { 29 | /// 30 | /// 31 | /// 32 | public class TestApplicationArgs 33 | { 34 | /// 35 | /// Gets or sets the record id. 36 | /// 37 | public int RecordId { get; set; } 38 | 39 | /// 40 | /// Gets or sets a value indicating whether this is silent. 41 | /// 42 | public bool Silent { get; set; } 43 | 44 | /// 45 | /// Gets or sets the new value. 46 | /// 47 | public string NewValue { get; set; } 48 | 49 | /// 50 | /// Gets or sets the Enum value. 51 | /// 52 | public TestEnum Enum { get; set; } 53 | } 54 | } -------------------------------------------------------------------------------- /FluentCommandLineParser.Tests/TestContext/TestContext.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | // TestContext.cs 3 | // Copyright (c) 2013, Simon Williams 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without modification, are permitted provide 7 | // d that the following conditions are met: 8 | // 9 | // Redistributions of source code must retain the above copyright notice, this list of conditions and the 10 | // following disclaimer. 11 | // 12 | // Redistributions in binary form must reproduce the above copyright notice, this list of conditions and 13 | // the following disclaimer in the documentation and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED 16 | // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 17 | // PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 18 | // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 19 | // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 21 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 22 | // POSSIBILITY OF SUCH DAMAGE. 23 | #endregion 24 | 25 | using System; 26 | using System.Collections.Generic; 27 | using System.Globalization; 28 | using System.Linq; 29 | using Fclp.Internals.Parsing; 30 | using Fclp.Tests.Internals; 31 | using Machine.Specifications; 32 | 33 | namespace Fclp.Tests 34 | { 35 | public abstract class TestContext : TestContextBase where T : class 36 | { 37 | protected static void CatchAnyError(Action test) 38 | { 39 | error = Catch.Exception(test); 40 | } 41 | 42 | protected static string[] CreateArgsFromKvp(IEnumerable kvps) 43 | { 44 | return kvps.Select(kvp => string.Format(CultureInfo.InvariantCulture, "/{0}:{1}", kvp.Key, kvp.Value)).ToArray(); 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /FluentCommandLineParser.Tests/app.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /FluentCommandLineParser.Tests/packages.config: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /FluentCommandLineParser.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | VisualStudioVersion = 12.0.31101.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FluentCommandLineParser", "FluentCommandLineParser\FluentCommandLineParser.csproj", "{74CDFA61-81D8-40F2-B536-949BABA15D3E}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FluentCommandLineParser.Tests", "FluentCommandLineParser.Tests\FluentCommandLineParser.Tests.csproj", "{A2546703-0B86-4515-BE5B-FAF85B756BDC}" 9 | EndProject 10 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{D8DCB1C2-5F18-4F40-A583-723975F89C1A}" 11 | ProjectSection(SolutionItems) = preProject 12 | .nuget\NuGet.Config = .nuget\NuGet.Config 13 | .nuget\NuGet.exe = .nuget\NuGet.exe 14 | .nuget\NuGet.targets = .nuget\NuGet.targets 15 | EndProjectSection 16 | EndProject 17 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FluentCommandLineParser.Examples", "FluentCommandLineParser.Examples\FluentCommandLineParser.Examples.csproj", "{47A9E194-B92E-4929-A7A8-396BCD46A844}" 18 | EndProject 19 | Global 20 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 21 | Debug|Any CPU = Debug|Any CPU 22 | Release|Any CPU = Release|Any CPU 23 | EndGlobalSection 24 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 25 | {74CDFA61-81D8-40F2-B536-949BABA15D3E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 26 | {74CDFA61-81D8-40F2-B536-949BABA15D3E}.Debug|Any CPU.Build.0 = Debug|Any CPU 27 | {74CDFA61-81D8-40F2-B536-949BABA15D3E}.Release|Any CPU.ActiveCfg = Release|Any CPU 28 | {74CDFA61-81D8-40F2-B536-949BABA15D3E}.Release|Any CPU.Build.0 = Release|Any CPU 29 | {A2546703-0B86-4515-BE5B-FAF85B756BDC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 30 | {A2546703-0B86-4515-BE5B-FAF85B756BDC}.Debug|Any CPU.Build.0 = Debug|Any CPU 31 | {A2546703-0B86-4515-BE5B-FAF85B756BDC}.Release|Any CPU.ActiveCfg = Release|Any CPU 32 | {A2546703-0B86-4515-BE5B-FAF85B756BDC}.Release|Any CPU.Build.0 = Release|Any CPU 33 | {47A9E194-B92E-4929-A7A8-396BCD46A844}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 34 | {47A9E194-B92E-4929-A7A8-396BCD46A844}.Debug|Any CPU.Build.0 = Debug|Any CPU 35 | {47A9E194-B92E-4929-A7A8-396BCD46A844}.Release|Any CPU.ActiveCfg = Release|Any CPU 36 | {47A9E194-B92E-4929-A7A8-396BCD46A844}.Release|Any CPU.Build.0 = Release|Any CPU 37 | EndGlobalSection 38 | GlobalSection(SolutionProperties) = preSolution 39 | HideSolutionNode = FALSE 40 | EndGlobalSection 41 | EndGlobal 42 | -------------------------------------------------------------------------------- /FluentCommandLineParser/CommandAlreadyExistsException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.Serialization; 3 | 4 | namespace Fclp 5 | { 6 | /// 7 | /// Represents an error that has occurred because a matching Command already exists in the parser. 8 | /// 9 | [Serializable] 10 | public class CommandAlreadyExistsException : Exception 11 | { 12 | /// 13 | /// Initialises a new instance of the class. 14 | /// 15 | public CommandAlreadyExistsException() { } 16 | 17 | /// 18 | /// Initialises a new instance of the class. 19 | /// 20 | /// 21 | public CommandAlreadyExistsException(string commandName) : base(commandName) { } 22 | 23 | /// 24 | /// Initialises a new instance of the class. 25 | /// 26 | /// 27 | /// 28 | public CommandAlreadyExistsException(SerializationInfo info, StreamingContext context) 29 | : base(info, context) { } 30 | 31 | /// 32 | /// Initialises a new instance of the class. 33 | /// 34 | /// 35 | /// 36 | public CommandAlreadyExistsException(string commandName, Exception innerException) 37 | : base(commandName, innerException) { } 38 | } 39 | } -------------------------------------------------------------------------------- /FluentCommandLineParser/CommandNotFoundException.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Runtime.Serialization; 3 | 4 | namespace Fclp 5 | { 6 | /// 7 | /// Represents an error that has occurred because an expected command was not found in the parser. 8 | /// 9 | [Serializable] 10 | public class CommandNotFoundException : Exception 11 | { 12 | /// 13 | /// Initialises a new instance of the class. 14 | /// 15 | public CommandNotFoundException() { } 16 | 17 | /// 18 | /// Initialises a new instance of the class. 19 | /// 20 | /// 21 | public CommandNotFoundException(string commandName) : base("Expected command " + commandName + " was not found in the parser.") { } 22 | 23 | /// 24 | /// Initialises a new instance of the class. 25 | /// 26 | /// 27 | /// 28 | public CommandNotFoundException(SerializationInfo info, StreamingContext context) 29 | : base(info, context) { } 30 | 31 | /// 32 | /// Initialises a new instance of the class. 33 | /// 34 | /// 35 | /// 36 | public CommandNotFoundException(string optionName, Exception innerException) 37 | : base(optionName, innerException) { } 38 | } 39 | } -------------------------------------------------------------------------------- /FluentCommandLineParser/FluentCommandLineBuilderT.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | // FluentCommandLineBuilderT.cs 3 | // Copyright (c) 2014, Simon Williams 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without modification, are permitted provide 7 | // d that the following conditions are met: 8 | // 9 | // Redistributions of source code must retain the above copyright notice, this list of conditions and the 10 | // following disclaimer. 11 | // 12 | // Redistributions in binary form must reproduce the above copyright notice, this list of conditions and 13 | // the following disclaimer in the documentation and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED 16 | // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 17 | // PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 18 | // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 19 | // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 21 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 22 | // POSSIBILITY OF SUCH DAMAGE. 23 | #endregion 24 | 25 | using System; 26 | 27 | namespace Fclp 28 | { 29 | /// 30 | /// Parser that constructs and populates the specified type of object from command line arguments. 31 | /// 32 | /// The object type containing the argument properties to populate from parsed command line arguments. 33 | [Obsolete("FluentCommandLineBuilder has been renamed to FluentCommandLineParser", false)] 34 | public class FluentCommandLineBuilder : FluentCommandLineParser, IFluentCommandLineBuilder where TBuildType : class, new() 35 | { 36 | 37 | } 38 | } -------------------------------------------------------------------------------- /FluentCommandLineParser/FluentCommandLineParser.nuspec: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | FluentCommandLineParser 5 | Fluent Command Line Parser 6 | $version$ 7 | siywilliams 8 | siywilliams 9 | http://fclp.github.com/fluent-command-line-parser 10 | false 11 | A simple, strongly typed .NET C# command line parser library using a fluent easy to use interface 12 | https://github.com/fclp/fluent-command-line-parser/wiki/Release-Notes 13 | Copyright Simon Williams 2012 - 2013 14 | fluent command line parser commandline c# net35 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /FluentCommandLineParser/ICommandLineCommand.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Linq.Expressions; 3 | 4 | namespace Fclp 5 | { 6 | /// 7 | /// Defines a fluent interface for settings up a command. 8 | /// 9 | public interface ICommandLineCommandFluent 10 | { 11 | /// 12 | /// 13 | /// 14 | /// 15 | /// 16 | ICommandLineCommandFluent OnSuccess(Action callback); 17 | 18 | /// 19 | /// Sets up an Option for a write-able property on the type being built. 20 | /// 21 | ICommandLineOptionBuilderFluent Setup(Expression> propertyPicker); 22 | } 23 | } -------------------------------------------------------------------------------- /FluentCommandLineParser/ICommandLineOptionFormatter.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | // ICommandLineOptionFormatter.cs 3 | // Copyright (c) 2013, Simon Williams 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without modification, are permitted provide 7 | // d that the following conditions are met: 8 | // 9 | // Redistributions of source code must retain the above copyright notice, this list of conditions and the 10 | // following disclaimer. 11 | // 12 | // Redistributions in binary form must reproduce the above copyright notice, this list of conditions and 13 | // the following disclaimer in the documentation and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED 16 | // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 17 | // PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 18 | // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 19 | // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 21 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 22 | // POSSIBILITY OF SUCH DAMAGE. 23 | #endregion 24 | 25 | using System; 26 | using System.Collections.Generic; 27 | using Fclp.Internals; 28 | 29 | namespace Fclp 30 | { 31 | /// 32 | /// Represents a formatter used to display command line options to the user. 33 | /// 34 | public interface ICommandLineOptionFormatter 35 | { 36 | /// 37 | /// Formats the list of to be displayed to the user. 38 | /// 39 | /// The list of to format. 40 | /// A representing the format 41 | /// If is null. 42 | string Format(IEnumerable options); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /FluentCommandLineParser/ICommandLineParserError.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | // ICommandLineParserError.cs 3 | // Copyright (c) 2013, Simon Williams 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without modification, are permitted provide 7 | // d that the following conditions are met: 8 | // 9 | // Redistributions of source code must retain the above copyright notice, this list of conditions and the 10 | // following disclaimer. 11 | // 12 | // Redistributions in binary form must reproduce the above copyright notice, this list of conditions and 13 | // the following disclaimer in the documentation and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED 16 | // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 17 | // PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 18 | // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 19 | // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 21 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 22 | // POSSIBILITY OF SUCH DAMAGE. 23 | #endregion 24 | 25 | using Fclp.Internals; 26 | 27 | namespace Fclp 28 | { 29 | /// 30 | /// Represents an error that has occurred whilst parsing a Option. 31 | /// 32 | public interface ICommandLineParserError 33 | { 34 | /// 35 | /// Gets the this error belongs too. 36 | /// 37 | ICommandLineOption Option { get; } 38 | } 39 | } -------------------------------------------------------------------------------- /FluentCommandLineParser/ICommandLineParserErrorFormatter.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | // ICommandLineParserErrorFormatter.cs 3 | // Copyright (c) 2013, Simon Williams 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without modification, are permitted provide 7 | // d that the following conditions are met: 8 | // 9 | // Redistributions of source code must retain the above copyright notice, this list of conditions and the 10 | // following disclaimer. 11 | // 12 | // Redistributions in binary form must reproduce the above copyright notice, this list of conditions and 13 | // the following disclaimer in the documentation and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED 16 | // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 17 | // PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 18 | // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 19 | // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 21 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 22 | // POSSIBILITY OF SUCH DAMAGE. 23 | #endregion 24 | 25 | using System.Collections.Generic; 26 | 27 | namespace Fclp 28 | { 29 | /// 30 | /// Represents a formatter used to format parser errors for display to the end user. 31 | /// 32 | public interface ICommandLineParserErrorFormatter 33 | { 34 | /// 35 | /// Formats the specified to a suitable for the end user. 36 | /// 37 | /// The error to format. This must not be null. 38 | /// A describing the specified error. 39 | string Format(ICommandLineParserError parserError); 40 | 41 | /// 42 | /// Formats the specified list of to a suitable for the end user. 43 | /// 44 | /// The errors to format. 45 | /// A describing the specified errors. 46 | string Format(IEnumerable parserErrors); 47 | } 48 | } -------------------------------------------------------------------------------- /FluentCommandLineParser/IFluentCommandLineBuilderT.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | // IFluentCommandLineBuilderT.cs 3 | // Copyright (c) 2014, Simon Williams 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without modification, are permitted provide 7 | // d that the following conditions are met: 8 | // 9 | // Redistributions of source code must retain the above copyright notice, this list of conditions and the 10 | // following disclaimer. 11 | // 12 | // Redistributions in binary form must reproduce the above copyright notice, this list of conditions and 13 | // the following disclaimer in the documentation and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED 16 | // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 17 | // PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 18 | // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 19 | // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 21 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 22 | // POSSIBILITY OF SUCH DAMAGE. 23 | #endregion 24 | 25 | using System; 26 | 27 | namespace Fclp 28 | { 29 | /// 30 | /// Parser that constructs and populates the specified type of object from command line arguments. 31 | /// 32 | [Obsolete("IFluentCommandLineBuilder has been renamed to IFluentCommandLineParser", false)] 33 | public interface IFluentCommandLineBuilder : IFluentCommandLineParser where TBuildType : class 34 | { 35 | 36 | } 37 | } -------------------------------------------------------------------------------- /FluentCommandLineParser/Internals/EmptyHelpCommandLineOption.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | // EmptyHelpCommandLineOption.cs 3 | // Copyright (c) 2013, Simon Williams 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without modification, are permitted provide 7 | // d that the following conditions are met: 8 | // 9 | // Redistributions of source code must retain the above copyright notice, this list of conditions and the 10 | // following disclaimer. 11 | // 12 | // Redistributions in binary form must reproduce the above copyright notice, this list of conditions and 13 | // the following disclaimer in the documentation and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED 16 | // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 17 | // PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 18 | // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 19 | // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 21 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 22 | // POSSIBILITY OF SUCH DAMAGE. 23 | #endregion 24 | 25 | using System; 26 | using System.Collections.Generic; 27 | using Fclp.Internals.Parsing; 28 | 29 | namespace Fclp.Internals 30 | { 31 | /// 32 | /// Help command line options used when there have been non setup. 33 | /// 34 | public class EmptyHelpCommandLineOption : IHelpCommandLineOption 35 | { 36 | /// 37 | /// Always returns false. 38 | /// 39 | /// The command line args. 40 | /// Type of the comparison. 41 | /// 42 | public bool ShouldShowHelp(IEnumerable commandLineArgs, StringComparison comparisonType) 43 | { 44 | return false; 45 | } 46 | 47 | /// 48 | /// Not supported. 49 | /// 50 | public void ShowHelp(IEnumerable options) 51 | { 52 | throw new NotSupportedException(); 53 | } 54 | } 55 | } -------------------------------------------------------------------------------- /FluentCommandLineParser/Internals/Errors/CommandLineParserErrorBase.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | // CommandLineParserErrorBase.cs 3 | // Copyright (c) 2013, Simon Williams 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without modification, are permitted provide 7 | // d that the following conditions are met: 8 | // 9 | // Redistributions of source code must retain the above copyright notice, this list of conditions and the 10 | // following disclaimer. 11 | // 12 | // Redistributions in binary form must reproduce the above copyright notice, this list of conditions and 13 | // the following disclaimer in the documentation and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED 16 | // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 17 | // PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 18 | // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 19 | // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 21 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 22 | // POSSIBILITY OF SUCH DAMAGE. 23 | #endregion 24 | 25 | using System; 26 | 27 | namespace Fclp.Internals.Errors 28 | { 29 | /// 30 | /// Contains error information regarding a failed parsing of a Option. 31 | /// 32 | public abstract class CommandLineParserErrorBase : ICommandLineParserError 33 | { 34 | /// 35 | /// Initialises a new instance of the class. 36 | /// 37 | /// The this error relates too. This must not be null. 38 | /// If is null. 39 | protected CommandLineParserErrorBase(ICommandLineOption cmdOption) 40 | { 41 | if (cmdOption == null) throw new ArgumentNullException("cmdOption"); 42 | this.Option = cmdOption; 43 | } 44 | 45 | /// 46 | /// Gets the this error belongs too. 47 | /// 48 | public virtual ICommandLineOption Option { get; private set; } 49 | } 50 | } -------------------------------------------------------------------------------- /FluentCommandLineParser/Internals/Errors/ExpectedOptionNotFoundParseError.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | // ExpectedOptionNotFoundParseError.cs 3 | // Copyright (c) 2013, Simon Williams 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without modification, are permitted provide 7 | // d that the following conditions are met: 8 | // 9 | // Redistributions of source code must retain the above copyright notice, this list of conditions and the 10 | // following disclaimer. 11 | // 12 | // Redistributions in binary form must reproduce the above copyright notice, this list of conditions and 13 | // the following disclaimer in the documentation and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED 16 | // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 17 | // PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 18 | // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 19 | // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 21 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 22 | // POSSIBILITY OF SUCH DAMAGE. 23 | #endregion 24 | 25 | using System; 26 | 27 | namespace Fclp.Internals.Errors 28 | { 29 | /// 30 | /// Represents a parse error that has occurred because an expected Option was not found. 31 | /// 32 | public class ExpectedOptionNotFoundParseError : CommandLineParserErrorBase 33 | { 34 | /// 35 | /// Initialises a new instance of the class. 36 | /// 37 | /// The this error relates too. This must not be null. 38 | /// If is null. 39 | public ExpectedOptionNotFoundParseError(ICommandLineOption cmdOption) : 40 | base(cmdOption) 41 | { 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /FluentCommandLineParser/Internals/ICommandLineOptionFactory.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | // ICommandLineOptionFactory.cs 3 | // Copyright (c) 2013, Simon Williams 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without modification, are permitted provide 7 | // d that the following conditions are met: 8 | // 9 | // Redistributions of source code must retain the above copyright notice, this list of conditions and the 10 | // following disclaimer. 11 | // 12 | // Redistributions in binary form must reproduce the above copyright notice, this list of conditions and 13 | // the following disclaimer in the documentation and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED 16 | // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 17 | // PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 18 | // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 19 | // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 21 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 22 | // POSSIBILITY OF SUCH DAMAGE. 23 | #endregion 24 | 25 | using System; 26 | 27 | namespace Fclp.Internals 28 | { 29 | /// 30 | /// Represents a factory capable of creating command line Options. 31 | /// 32 | public interface ICommandLineOptionFactory 33 | { 34 | /// 35 | /// Creates a new . 36 | /// 37 | /// The type of to create. 38 | /// The short name for this Option. This must not be null, empty or contain only whitespace. 39 | /// The long name for this Option or null if not required. 40 | /// Thrown if is null, empty or contains only whitespace. 41 | /// A . 42 | ICommandLineOptionResult CreateOption(string shortName, string longName); 43 | 44 | /// 45 | /// Create a new using the specified args. 46 | /// 47 | /// The args used to display the help option. 48 | IHelpCommandLineOptionResult CreateHelpOption(string[] helpArgs); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /FluentCommandLineParser/Internals/ICommandLineOptionResult.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | // ICommandLineOptionResult.cs 3 | // Copyright (c) 2013, Simon Williams 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without modification, are permitted provide 7 | // d that the following conditions are met: 8 | // 9 | // Redistributions of source code must retain the above copyright notice, this list of conditions and the 10 | // following disclaimer. 11 | // 12 | // Redistributions in binary form must reproduce the above copyright notice, this list of conditions and 13 | // the following disclaimer in the documentation and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED 16 | // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 17 | // PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 18 | // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 19 | // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 21 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 22 | // POSSIBILITY OF SUCH DAMAGE. 23 | #endregion 24 | namespace Fclp.Internals 25 | { 26 | /// 27 | /// Used to encapsulate both command Option interfaces which are returned from the factory. 28 | /// 29 | /// The type of Option. 30 | public interface ICommandLineOptionResult : ICommandLineOption, ICommandLineOptionFluent 31 | { 32 | 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /FluentCommandLineParser/Internals/IHelpCommandLineOption.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | // IHelpCommandLineOption.cs 3 | // Copyright (c) 2013, Simon Williams 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without modification, are permitted provide 7 | // d that the following conditions are met: 8 | // 9 | // Redistributions of source code must retain the above copyright notice, this list of conditions and the 10 | // following disclaimer. 11 | // 12 | // Redistributions in binary form must reproduce the above copyright notice, this list of conditions and 13 | // the following disclaimer in the documentation and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED 16 | // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 17 | // PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 18 | // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 19 | // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 21 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 22 | // POSSIBILITY OF SUCH DAMAGE. 23 | #endregion 24 | 25 | using System; 26 | using System.Collections.Generic; 27 | using Fclp.Internals.Parsing; 28 | 29 | namespace Fclp.Internals 30 | { 31 | /// 32 | /// Represents a command line option that determines whether to show the help text. 33 | /// 34 | public interface IHelpCommandLineOption 35 | { 36 | /// 37 | /// Determines whether the help text should be shown. 38 | /// 39 | /// The parsed command line arguments 40 | /// The type of comparison to use when comparing Option names. 41 | /// true if the parser operation should cease and should be called; otherwise false if the parse operation to continue. 42 | bool ShouldShowHelp(IEnumerable parsedOptions, StringComparison comparisonType); 43 | 44 | /// 45 | /// Shows the help text for the specified registered options. 46 | /// 47 | /// The options to generate the help text for. 48 | void ShowHelp(IEnumerable options); 49 | } 50 | } -------------------------------------------------------------------------------- /FluentCommandLineParser/Internals/IHelpCommandLineOptionResult.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | // IHelpCommandLineOptionResult.cs 3 | // Copyright (c) 2013, Simon Williams 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without modification, are permitted provide 7 | // d that the following conditions are met: 8 | // 9 | // Redistributions of source code must retain the above copyright notice, this list of conditions and the 10 | // following disclaimer. 11 | // 12 | // Redistributions in binary form must reproduce the above copyright notice, this list of conditions and 13 | // the following disclaimer in the documentation and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED 16 | // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 17 | // PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 18 | // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 19 | // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 21 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 22 | // POSSIBILITY OF SUCH DAMAGE. 23 | #endregion 24 | namespace Fclp.Internals 25 | { 26 | /// 27 | /// Used to encapsulate both help command option interfaces which are returned from the factory. 28 | /// 29 | public interface IHelpCommandLineOptionResult : IHelpCommandLineOption, IHelpCommandLineOptionFluent 30 | { 31 | 32 | } 33 | } -------------------------------------------------------------------------------- /FluentCommandLineParser/Internals/Parsing/ICommandLineOptionParserFactory.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | // ICommandLineOptionParserFactory.cs 3 | // Copyright (c) 2013, Simon Williams 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without modification, are permitted provide 7 | // d that the following conditions are met: 8 | // 9 | // Redistributions of source code must retain the above copyright notice, this list of conditions and the 10 | // following disclaimer. 11 | // 12 | // Redistributions in binary form must reproduce the above copyright notice, this list of conditions and 13 | // the following disclaimer in the documentation and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED 16 | // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 17 | // PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 18 | // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 19 | // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 21 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 22 | // POSSIBILITY OF SUCH DAMAGE. 23 | #endregion 24 | 25 | using Fclp.Internals.Parsing.OptionParsers; 26 | 27 | namespace Fclp.Internals.Parsing 28 | { 29 | /// 30 | /// Represents a factory capable of creating . 31 | /// 32 | public interface ICommandLineOptionParserFactory 33 | { 34 | /// 35 | /// Creates a to handle the specified type. 36 | /// 37 | /// The type of parser to create. 38 | /// A suitable for the specified type. 39 | /// If the specified type is not supported by this factory. 40 | ICommandLineOptionParser CreateParser(); 41 | } 42 | } -------------------------------------------------------------------------------- /FluentCommandLineParser/Internals/Parsing/ICommandLineParserEngine.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | // ICommandLineParserEngine.cs 3 | // Copyright (c) 2013, Simon Williams 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without modification, are permitted provide 7 | // d that the following conditions are met: 8 | // 9 | // Redistributions of source code must retain the above copyright notice, this list of conditions and the 10 | // following disclaimer. 11 | // 12 | // Redistributions in binary form must reproduce the above copyright notice, this list of conditions and 13 | // the following disclaimer in the documentation and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED 16 | // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 17 | // PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 18 | // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 19 | // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 21 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 22 | // POSSIBILITY OF SUCH DAMAGE. 23 | #endregion 24 | 25 | namespace Fclp.Internals.Parsing 26 | { 27 | /// 28 | /// Responsible for parsing command line arguments into simple key and value pairs. 29 | /// 30 | public interface ICommandLineParserEngine 31 | { 32 | /// 33 | /// Parses the specified T:System.String[] into key value pairs. 34 | /// 35 | /// The T:System.String[] to parse. 36 | /// true to parse any commands, false to skip commands. 37 | /// An representing the results of the parse operation. 38 | ParserEngineResult Parse(string[] args, bool parseCommands); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /FluentCommandLineParser/Internals/Parsing/OptionParsers/DoubleCommandLineOptionParser.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | // DoubleCommandLineOptionParser.cs 3 | // Copyright (c) 2013, Simon Williams 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without modification, are permitted provide 7 | // d that the following conditions are met: 8 | // 9 | // Redistributions of source code must retain the above copyright notice, this list of conditions and the 10 | // following disclaimer. 11 | // 12 | // Redistributions in binary form must reproduce the above copyright notice, this list of conditions and 13 | // the following disclaimer in the documentation and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED 16 | // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 17 | // PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 18 | // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 19 | // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 21 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 22 | // POSSIBILITY OF SUCH DAMAGE. 23 | #endregion 24 | 25 | using System.Globalization; 26 | 27 | namespace Fclp.Internals.Parsing.OptionParsers 28 | { 29 | /// 30 | /// Parser used to convert to . 31 | /// 32 | public class DoubleCommandLineOptionParser : ICommandLineOptionParser 33 | { 34 | /// 35 | /// Parses the specified into a . 36 | /// 37 | /// 38 | /// 39 | public double Parse(ParsedOption parsedOption) 40 | { 41 | return double.Parse(parsedOption.Value, CultureInfo.InvariantCulture); 42 | } 43 | 44 | /// 45 | /// Determines whether the specified can be parsed by this . 46 | /// 47 | /// 48 | /// true if the specified can be parsed by this ; otherwise false. 49 | public bool CanParse(ParsedOption parsedOption) 50 | { 51 | double result; 52 | return double.TryParse(parsedOption.Value, System.Globalization.NumberStyles.Number, CultureInfo.InvariantCulture, out result); 53 | } 54 | } 55 | } -------------------------------------------------------------------------------- /FluentCommandLineParser/Internals/Parsing/OptionParsers/ICommandLineOptionParser.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | // ICommandLineOptionParser.cs 3 | // Copyright (c) 2013, Simon Williams 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without modification, are permitted provide 7 | // d that the following conditions are met: 8 | // 9 | // Redistributions of source code must retain the above copyright notice, this list of conditions and the 10 | // following disclaimer. 11 | // 12 | // Redistributions in binary form must reproduce the above copyright notice, this list of conditions and 13 | // the following disclaimer in the documentation and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED 16 | // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 17 | // PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 18 | // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 19 | // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 21 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 22 | // POSSIBILITY OF SUCH DAMAGE. 23 | #endregion 24 | namespace Fclp.Internals.Parsing.OptionParsers 25 | { 26 | /// 27 | /// Represents a parser for a Option that can convert a value into the required type. 28 | /// 29 | public interface ICommandLineOptionParser 30 | { 31 | /// 32 | /// Parses the specified into the return type. 33 | /// 34 | /// 35 | /// The parsed value. 36 | T Parse(ParsedOption parsedOption); 37 | 38 | /// 39 | /// Determines whether the specified can be parsed by this . 40 | /// 41 | /// 42 | /// true if the specified can be parsed by this ; otherwise false. 43 | bool CanParse(ParsedOption parsedOption); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /FluentCommandLineParser/Internals/Parsing/OptionParsers/Int32CommandLineOptionParser.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | // Int32CommandLineOptionParser.cs 3 | // Copyright (c) 2013, Simon Williams 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without modification, are permitted provide 7 | // d that the following conditions are met: 8 | // 9 | // Redistributions of source code must retain the above copyright notice, this list of conditions and the 10 | // following disclaimer. 11 | // 12 | // Redistributions in binary form must reproduce the above copyright notice, this list of conditions and 13 | // the following disclaimer in the documentation and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED 16 | // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 17 | // PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 18 | // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 19 | // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 21 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 22 | // POSSIBILITY OF SUCH DAMAGE. 23 | #endregion 24 | 25 | using System.Globalization; 26 | 27 | namespace Fclp.Internals.Parsing.OptionParsers 28 | { 29 | /// 30 | /// Parser used to convert to . 31 | /// 32 | public class Int32CommandLineOptionParser : ICommandLineOptionParser 33 | { 34 | /// 35 | /// Converts the string representation of a number in a specified culture-specific format to its 32-bit signed integer equivalent. 36 | /// 37 | /// 38 | /// 39 | public int Parse(ParsedOption parsedOption) 40 | { 41 | return int.Parse(parsedOption.Value, CultureInfo.CurrentCulture); 42 | } 43 | 44 | /// 45 | /// Determines whether the specified can be parsed by this . 46 | /// 47 | /// 48 | /// true if the specified can be parsed by this ; otherwise false. 49 | public bool CanParse(ParsedOption parsedOption) 50 | { 51 | int result; 52 | return int.TryParse(parsedOption.Value, out result); 53 | } 54 | } 55 | } -------------------------------------------------------------------------------- /FluentCommandLineParser/Internals/Parsing/OptionParsers/Int64CommandLineOptionParser.cs: -------------------------------------------------------------------------------- 1 | using System.Globalization; 2 | 3 | namespace Fclp.Internals.Parsing.OptionParsers 4 | { 5 | /// 6 | /// Parser used to convert to . 7 | /// 8 | public class Int64CommandLineOptionParser : ICommandLineOptionParser 9 | { 10 | /// 11 | /// Converts the string representation of a number in a specified culture-specific format to its 64-bit signed integer equivalent. 12 | /// 13 | /// 14 | /// 15 | public long Parse(ParsedOption parsedOption) 16 | { 17 | return long.Parse(parsedOption.Value, CultureInfo.CurrentCulture); 18 | } 19 | 20 | /// 21 | /// Determines whether the specified can be parsed by this . 22 | /// 23 | /// 24 | /// true if the specified can be parsed by this ; otherwise false. 25 | public bool CanParse(ParsedOption parsedOption) 26 | { 27 | long result; 28 | return long.TryParse(parsedOption.Value, out result); 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /FluentCommandLineParser/Internals/SpecialCharacters.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | // SpecialCharacters.cs 3 | // Copyright (c) 2013, Simon Williams 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without modification, are permitted provide 7 | // d that the following conditions are met: 8 | // 9 | // Redistributions of source code must retain the above copyright notice, this list of conditions and the 10 | // following disclaimer. 11 | // 12 | // Redistributions in binary form must reproduce the above copyright notice, this list of conditions and 13 | // the following disclaimer in the documentation and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED 16 | // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 17 | // PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 18 | // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 19 | // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 21 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 22 | // POSSIBILITY OF SUCH DAMAGE. 23 | #endregion 24 | 25 | using System.Collections.Generic; 26 | 27 | namespace Fclp.Internals 28 | { 29 | /// 30 | /// Contains special characters used throughout the parser. 31 | /// 32 | public class SpecialCharacters 33 | { 34 | /// 35 | /// Characters used for value assignment. 36 | /// 37 | public char[] ValueAssignments { get; private set; } = new[] { '=', ':' }; 38 | 39 | /// 40 | /// Assign a name to the whitespace character. 41 | /// 42 | public char Whitespace { get; set; } = ' '; 43 | 44 | /// 45 | /// Characters that define the start of an option. 46 | /// 47 | public List OptionPrefix { get; private set; } = new List { "/", "--", "-" }; 48 | 49 | /// 50 | /// Characters that have special meaning at the end of an option key. 51 | /// 52 | public List OptionSuffix { get; private set; } = new List { "+", "-" }; 53 | 54 | /// s 55 | /// Characters that define an explicit short option. 56 | /// 57 | public List ShortOptionPrefix { get; private set; } = new List { "-" }; 58 | 59 | /// 60 | /// The key that indicates the end of any options. 61 | /// Any following arguments should be treated as operands, even if they begin with the '-' character. 62 | /// 63 | public string EndOfOptionsKey { get; set; } = "--"; 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /FluentCommandLineParser/Internals/Validators/CommandLineOptionValidator.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | // CommandLineOptionValidator.cs 3 | // Copyright (c) 2013, Simon Williams 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without modification, are permitted provide 7 | // d that the following conditions are met: 8 | // 9 | // Redistributions of source code must retain the above copyright notice, this list of conditions and the 10 | // following disclaimer. 11 | // 12 | // Redistributions in binary form must reproduce the above copyright notice, this list of conditions and 13 | // the following disclaimer in the documentation and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED 16 | // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 17 | // PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 18 | // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 19 | // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 21 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 22 | // POSSIBILITY OF SUCH DAMAGE. 23 | #endregion 24 | 25 | using System; 26 | using System.Collections.Generic; 27 | 28 | namespace Fclp.Internals.Validators 29 | { 30 | /// 31 | /// Wrapping validator that executes all the individual validation rules. 32 | /// 33 | public class CommandLineOptionValidator : ICommandLineOptionValidator 34 | { 35 | private readonly IList _rules; 36 | 37 | /// 38 | /// Initialises a new instance of the class. 39 | /// 40 | public CommandLineOptionValidator(ICommandLineOptionContainer container, SpecialCharacters specialCharacters) 41 | { 42 | _rules = new List 43 | { 44 | new OptionNameValidator(specialCharacters), 45 | new NoDuplicateOptionValidator(container) 46 | }; 47 | } 48 | 49 | /// 50 | /// Validates the specified against all the registered rules. 51 | /// 52 | /// The to validate. 53 | /// 54 | public void Validate(ICommandLineOption commandLineOption, StringComparison stringComparison) 55 | { 56 | foreach (var rule in _rules) 57 | { 58 | rule.Validate(commandLineOption, stringComparison); 59 | } 60 | } 61 | } 62 | } -------------------------------------------------------------------------------- /FluentCommandLineParser/Internals/Validators/ICommandLineOptionValidator.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | // ICommandLineOptionValidator.cs 3 | // Copyright (c) 2013, Simon Williams 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without modification, are permitted provide 7 | // d that the following conditions are met: 8 | // 9 | // Redistributions of source code must retain the above copyright notice, this list of conditions and the 10 | // following disclaimer. 11 | // 12 | // Redistributions in binary form must reproduce the above copyright notice, this list of conditions and 13 | // the following disclaimer in the documentation and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED 16 | // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 17 | // PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 18 | // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 19 | // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 21 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 22 | // POSSIBILITY OF SUCH DAMAGE. 23 | #endregion 24 | 25 | using System; 26 | 27 | namespace Fclp.Internals.Validators 28 | { 29 | /// 30 | /// Represents a validator used to verify new setup command line options. 31 | /// 32 | public interface ICommandLineOptionValidator 33 | { 34 | /// 35 | /// Verifies that the proposed new is a valid new Option. 36 | /// 37 | /// The to validate. This must not be null. 38 | /// 39 | void Validate(ICommandLineOption commandLineOption, StringComparison stringComparison); 40 | } 41 | } -------------------------------------------------------------------------------- /FluentCommandLineParser/OptionAlreadyExistsException.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | // OptionAlreadyExistsException.cs 3 | // Copyright (c) 2013, Simon Williams 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without modification, are permitted provide 7 | // d that the following conditions are met: 8 | // 9 | // Redistributions of source code must retain the above copyright notice, this list of conditions and the 10 | // following disclaimer. 11 | // 12 | // Redistributions in binary form must reproduce the above copyright notice, this list of conditions and 13 | // the following disclaimer in the documentation and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED 16 | // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 17 | // PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 18 | // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 19 | // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 21 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 22 | // POSSIBILITY OF SUCH DAMAGE. 23 | #endregion 24 | 25 | using System; 26 | using System.Runtime.Serialization; 27 | 28 | namespace Fclp 29 | { 30 | /// 31 | /// Represents an error that has occurred because a matching Option already exists in the parser. 32 | /// 33 | [Serializable] 34 | public class OptionAlreadyExistsException : Exception 35 | { 36 | /// 37 | /// Initialises a new instance of the class. 38 | /// 39 | public OptionAlreadyExistsException() { } 40 | 41 | /// 42 | /// Initialises a new instance of the class. 43 | /// 44 | /// 45 | public OptionAlreadyExistsException(string optionName) : base(optionName) { } 46 | 47 | /// 48 | /// Initialises a new instance of the class. 49 | /// 50 | /// 51 | /// 52 | public OptionAlreadyExistsException(SerializationInfo info, StreamingContext context) 53 | : base(info, context) { } 54 | 55 | /// 56 | /// Initialises a new instance of the class. 57 | /// 58 | /// 59 | /// 60 | public OptionAlreadyExistsException(string optionName, Exception innerException) 61 | : base(optionName, innerException) { } 62 | 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /FluentCommandLineParser/OptionSyntaxException.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | // OptionSyntaxException.cs 3 | // Copyright (c) 2013, Simon Williams 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without modification, are permitted provide 7 | // d that the following conditions are met: 8 | // 9 | // Redistributions of source code must retain the above copyright notice, this list of conditions and the 10 | // following disclaimer. 11 | // 12 | // Redistributions in binary form must reproduce the above copyright notice, this list of conditions and 13 | // the following disclaimer in the documentation and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED 16 | // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 17 | // PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 18 | // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 19 | // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 21 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 22 | // POSSIBILITY OF SUCH DAMAGE. 23 | #endregion 24 | 25 | using System; 26 | 27 | namespace Fclp 28 | { 29 | /// 30 | /// Represents an error that has occurred because a Option syntax was in an unexpected format. 31 | /// 32 | [Serializable] 33 | public class OptionSyntaxException : Exception 34 | { 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /FluentCommandLineParser/ParseSequence.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | // OptionSyntaxException.cs 3 | // Copyright (c) 2917, Simon Williams 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without modification, are permitted provide 7 | // d that the following conditions are met: 8 | // 9 | // Redistributions of source code must retain the above copyright notice, this list of conditions and the 10 | // following disclaimer. 11 | // 12 | // Redistributions in binary form must reproduce the above copyright notice, this list of conditions and 13 | // the following disclaimer in the documentation and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED 16 | // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 17 | // PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 18 | // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 19 | // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 21 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 22 | // POSSIBILITY OF SUCH DAMAGE. 23 | #endregion 24 | 25 | namespace Fclp 26 | { 27 | /// 28 | /// option/callback execute sequence 29 | /// 30 | public enum ParseSequence 31 | { 32 | /// 33 | /// same as the setup sequence, early setup higher priority 34 | /// 35 | SameAsSetup = 0, 36 | 37 | /// 38 | /// same as the cmd input options sequence 39 | /// 40 | SameAsOptions 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /FluentCommandLineParser/UnsupportedTypeException.cs: -------------------------------------------------------------------------------- 1 | #region License 2 | // UnsupportedTypeException.cs 3 | // Copyright (c) 2013, Simon Williams 4 | // All rights reserved. 5 | // 6 | // Redistribution and use in source and binary forms, with or without modification, are permitted provide 7 | // d that the following conditions are met: 8 | // 9 | // Redistributions of source code must retain the above copyright notice, this list of conditions and the 10 | // following disclaimer. 11 | // 12 | // Redistributions in binary form must reproduce the above copyright notice, this list of conditions and 13 | // the following disclaimer in the documentation and/or other materials provided with the distribution. 14 | // 15 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED 16 | // WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 17 | // PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 18 | // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 19 | // TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 | // HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 21 | // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 22 | // POSSIBILITY OF SUCH DAMAGE. 23 | #endregion 24 | 25 | using System; 26 | 27 | namespace Fclp 28 | { 29 | /// 30 | /// Represents an error that has occurred because a specified type is unsupported. 31 | /// 32 | [Serializable] 33 | public class UnsupportedTypeException : Exception 34 | { 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /LICENCE.txt: -------------------------------------------------------------------------------- 1 | FreeBSD License 2 | 3 | Fluent Command Line Parser 4 | Copyright (c) 2012 - 2013, Simon Williams 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without modification, are permitted provide 8 | d that the following conditions are met: 9 | 10 | Redistributions of source code must retain the above copyright notice, this list of conditions and the 11 | following disclaimer. 12 | 13 | Redistributions in binary form must reproduce the above copyright notice, this list of conditions and 14 | the following disclaimer in the documentationand/or other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED 17 | WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 18 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR 19 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 20 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 22 | NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 23 | POSSIBILITY OF SUCH DAMAGE. --------------------------------------------------------------------------------