public void ParseInteger1()
        {
            var valueArgument = new ValueArgument <int>("i", "")
            {
                AllowMultiple = true
            };
            var argument = new SwitchValueArgument <int>("Value", valueArgument, "Description", null, new[] { 'v' })
            {
                Category   = "Category",
                IsOptional = true,
            };

            Assert.AreEqual("Value", argument.Name);
            Assert.AreEqual('v', argument.ShortAliases[0]);
            Assert.AreEqual("Description", argument.Description);
            Assert.AreEqual("Category", argument.Category);
            Assert.IsFalse(string.IsNullOrEmpty(argument.GetSyntax()));
            Assert.IsFalse(string.IsNullOrEmpty(argument.GetHelp()));

            int i = 0;

            string[] args   = { "--value:1", "23", "4", };
            var      result = (ArgumentResult <int>)argument.Parse(args, ref i);

            Assert.AreEqual(3, i);
            Assert.IsNotNull(result.Values);
            Assert.AreEqual(3, result.Values.Count);
            Assert.AreEqual(1, result.Values[0]);
            Assert.AreEqual(23, result.Values[1]);
            Assert.AreEqual(4, result.Values[2]);
        }
示例#2
0
        public void ParseInteger1()
        {
            var valueArgument = new ValueArgument<int>("i", "") { AllowMultiple = true };
            var argument = new SwitchValueArgument<int>("Value", valueArgument, "Description", null, new[] { 'v' })
            {
                Category = "Category",
                IsOptional = true,
            };

            Assert.AreEqual("Value", argument.Name);
            Assert.AreEqual('v', argument.ShortAliases[0]);
            Assert.AreEqual("Description", argument.Description);
            Assert.AreEqual("Category", argument.Category);
            Assert.IsFalse(string.IsNullOrEmpty(argument.GetSyntax()));
            Assert.IsFalse(string.IsNullOrEmpty(argument.GetHelp()));

            int i = 0;
            string[] args = { "--value:1", "23", "4", };
            var result = (ArgumentResult<int>)argument.Parse(args, ref i);
            Assert.AreEqual(3, i);
            Assert.IsNotNull(result.Values);
            Assert.AreEqual(3, result.Values.Count);
            Assert.AreEqual(1, result.Values[0]);
            Assert.AreEqual(23, result.Values[1]);
            Assert.AreEqual(4, result.Values[2]);
        }
 private void AddCommandLineArguments()
 {
     // Add command-line argument "--layout <layout_name>"
     _layoutArgument = new SwitchValueArgument <string>(
         "layout",
         new ValueArgument <string>("name", "The name of the layout."),
         "Specifies the layout to open on startup.")
     {
         IsOptional = true,
         Category   = "UI",
     };
     Editor.CommandLineParser.Arguments.Add(_layoutArgument);
 }
示例#4
0
 private void AddCommandLineArguments()
 {
     // Add command-line argument "--layout <layout_name>"
     _layoutArgument = new SwitchValueArgument<string>(
         "layout",
         new ValueArgument<string>("name", "The name of the layout."),
         "Specifies the layout to open on startup.")
     {
         IsOptional = true,
         Category = "UI",
     };
     Editor.CommandLineParser.Arguments.Add(_layoutArgument);
 }
示例#5
0
        public void MissingFlag()
        {
            var valueArg = new EnumArgument<MyFlags>("MyFlags", "") { IsOptional = false };
            var argument = new SwitchValueArgument<MyFlags>("Flags", valueArg, "Description", null, new[] { 'f' })
            {
                Category = "Category",
                IsOptional = true,
            };

            int i = 0;
            string[] args = { "-f", };

            Assert.Throws<MissingArgumentException>(() => argument.Parse(args, ref i));
        }
        public void MissingFlag()
        {
            var valueArg = new EnumArgument <MyFlags>("MyFlags", "")
            {
                IsOptional = false
            };
            var argument = new SwitchValueArgument <MyFlags>("Flags", valueArg, "Description", null, new[] { 'f' })
            {
                Category   = "Category",
                IsOptional = true,
            };

            int i = 0;

            string[] args = { "-f", };

            Assert.Throws <MissingArgumentException>(() => argument.Parse(args, ref i));
        }
示例#7
0
        public void ParseFlags()
        {
            var valueArg = new EnumArgument<MyFlags>("MyFlags", "") { IsOptional = true };
            var argument = new SwitchValueArgument<MyFlags>("Flags", valueArg, "Description", null, new[] { 'f' })
            {
                Category = "Category",
                IsOptional = true,
            };

            int i = 0;
            string[] args = { "--flags:flag1", "flag3", };
            var result = (ArgumentResult<MyFlags>)argument.Parse(args, ref i);
            Assert.AreEqual(2, i);
            Assert.IsNotNull(result.Values);
            Assert.AreEqual(2, result.Values.Count);
            Assert.AreEqual(MyFlags.Flag1, result.Values[0]);
            Assert.AreEqual(MyFlags.Flag3, result.Values[1]);
        }
        public void ParseOptionalFlags()
        {
            var valueArg = new EnumArgument <MyFlags>("MyFlags", "")
            {
                IsOptional = true
            };
            var argument = new SwitchValueArgument <MyFlags>("Flags", valueArg, "Description", null, new[] { 'f' })
            {
                Category   = "Category",
                IsOptional = true,
            };

            int i = 0;

            string[] args   = { "-f", };
            var      result = (ArgumentResult <MyFlags>)argument.Parse(args, ref i);

            Assert.AreEqual(1, i);
            Assert.IsTrue(result.Values == null || result.Values.Count == 0);
        }
        public void ParseInteger2()
        {
            var valueArg = new ValueArgument <int>("i", "")
            {
                AllowMultiple = false, IsOptional = true
            };
            var argument = new SwitchValueArgument <int>("Value", valueArg, "Description", null, new[] { 'v' })
            {
                Category   = "Category",
                IsOptional = true,
            };

            int i = 0;

            string[] args   = { "--value:1", "23", "4", "other" };
            var      result = (ArgumentResult <int>)argument.Parse(args, ref i);

            Assert.AreEqual(1, i);
            Assert.AreEqual(1, result.Values.Count);
            Assert.AreEqual(1, result.Values[0]);
        }
        public void ParseFlags()
        {
            var valueArg = new EnumArgument <MyFlags>("MyFlags", "")
            {
                IsOptional = true
            };
            var argument = new SwitchValueArgument <MyFlags>("Flags", valueArg, "Description", null, new[] { 'f' })
            {
                Category   = "Category",
                IsOptional = true,
            };

            int i = 0;

            string[] args   = { "--flags:flag1", "flag3", };
            var      result = (ArgumentResult <MyFlags>)argument.Parse(args, ref i);

            Assert.AreEqual(2, i);
            Assert.IsNotNull(result.Values);
            Assert.AreEqual(2, result.Values.Count);
            Assert.AreEqual(MyFlags.Flag1, result.Values[0]);
            Assert.AreEqual(MyFlags.Flag3, result.Values[1]);
        }
示例#11
0
        public void ParseOptionalFlags()
        {
            var valueArg = new EnumArgument<MyFlags>("MyFlags", "") { IsOptional = true };
            var argument = new SwitchValueArgument<MyFlags>("Flags", valueArg, "Description", null, new[] { 'f' })
            {
                Category = "Category",
                IsOptional = true,
            };

            int i = 0;
            string[] args = { "-f", };
            var result = (ArgumentResult<MyFlags>)argument.Parse(args, ref i);
            Assert.AreEqual(1, i);
            Assert.IsTrue(result.Values == null || result.Values.Count == 0);
        }
示例#12
0
        private void AddTestArguments(CommandLineParser parser)
        {
            SwitchArgument helpArgument = new SwitchArgument("help", "Show help.", null, new[] { 'h', '?' })
            {
                Category   = "Help",
                IsOptional = true,
            };

            parser.Arguments.Add(helpArgument);

            ValueArgument <string> fileArgument = new ValueArgument <string>("file", "The file to load.")
            {
                Category      = "",
                IsOptional    = true,
                AllowMultiple = true,
            };

            parser.Arguments.Add(fileArgument);

            SwitchArgument recursiveArgument = new SwitchArgument("Recursive", "Enables recursive mode.", null, new[] { 'R' })
            {
                Category   = null,
                IsOptional = true
            };

            parser.Arguments.Add(recursiveArgument);

            SwitchArgument switchArgument1 = new SwitchArgument("Switch", "Another test switch.", null, new[] { 'S' })
            {
                Category   = "Test Category",
                IsOptional = true,
            };

            parser.Arguments.Add(switchArgument1);

            SwitchValueArgument <int> valueArgument = new SwitchValueArgument <int>(
                "value",
                new ValueArgument <int>("value", "The value.")
            {
                AllowMultiple = true
            },
                "This switch has a value.",
                null,
                new[] { 'v' })
            {
                Category   = "Test Category 2",
                IsOptional = true,
            };

            parser.Arguments.Add(valueArgument);

            SwitchValueArgument <float> boundedArgument = new SwitchValueArgument <float>(
                "bounded",
                new BoundedValueArgument <float>("value", "The value.", 1, 5)
            {
                AllowMultiple = true
            },
                "This is a bounded value.",
                null,
                new[] { 'b' })
            {
                Category   = "Test Category 2",
                IsOptional = true,
            };

            parser.Arguments.Add(boundedArgument);

            SwitchValueArgument <MyEnum> enumArgument = new SwitchValueArgument <MyEnum>(
                "Enum",
                new EnumArgument <MyEnum>("MyEnum", "The value."),
                "This is an enumeration.",
                null,
                new[] { 'e' })
            {
                Category   = "Test Category 2",
                IsOptional = true,
            };

            parser.Arguments.Add(enumArgument);

            SwitchValueArgument <MyFlags> flagsArgument = new SwitchValueArgument <MyFlags>(
                "Flags",
                new EnumArgument <MyFlags>("MyFlags", "The value."),
                "This is a combination of flags (= enumeration with FlagsAttribute).",
                null,
                new[] { 'f' })
            {
                Category   = "Test Category 2",
                IsOptional = true,
            };

            parser.Arguments.Add(flagsArgument);
        }
示例#13
0
        private static CommandLineParser ConfigureCommandLine()
        {
            var parser = new CommandLineParser
            {
                AllowUnknownArguments = false,

                Description =
                    @"This command-line tool can be used to pack files and directories into a single
package. The resulting package file uses the ZIP format and can be read with
standard ZIP tools.",

                HelpHeader =
                    @"If no package exists at the target location, a new file is created.
When the package already exists, it is updated.The input files are compared
with the packaged files. New files are added, modified files are updated, and
missing files are removed from the package. Files are compared by checking the
""Last Modified"" time and the file size.",

                HelpFooter =
                    @"Credits
-------
Pack.exe - Copyright (C) 2014 DigitalRune GmbH. All rights reserved.
DotNetZip - Copyright (C) 2006-2011 Dino Chiesa. All rights reserved.
jzlib - Copyright (C) 2000-2003 ymnk, JCraft,Inc. All rights reserved.
zlib - Copyright (C) 1995-2004 Jean-loup Gailly and Mark Adler."
            };

            var categoryMandatory = "Mandatory";
            var categoryOptional  = "Optional";

            // ----- Mandatory arguments

            // Input files
            _inputArgument = new ValueArgument <string>(
                "files",
                @"Defines the files and directories to add to the package.
The specified files and directories are relative to the current working copy or the base directory, which can be specified with /directory.
Wildcards ('?', '*') are supported.")
            {
                Category      = categoryMandatory,
                AllowMultiple = true,
            };
            parser.Arguments.Add(_inputArgument);

            // --output, --out, -o
            _outputArgument = new SwitchValueArgument <string>(
                "output",
                new ValueArgument <string>("package", "The filename incl. path of package."),
                "Defines the package to create or update.",
                new[] { "out" },
                new[] { 'o' })
            {
                Category = categoryMandatory,
            };
            parser.Arguments.Add(_outputArgument);

            // ----- Optional arguments

            // --directory, --dir, -d
            _directoryArgument = new SwitchValueArgument <string>(
                "directory",
                new ValueArgument <string>("directory", "The base directory."),
                "Specifies the base directory where to search for files.",
                new[] { "dir" },
                new[] { 'd' })
            {
                Category   = categoryOptional,
                IsOptional = true,
            };
            parser.Arguments.Add(_directoryArgument);

            // --recursive, --rec, -r
            _recursiveArgument = new SwitchArgument(
                "recursive",
                "Adds subdirectories to package.",
                new[] { "rec" },
                new[] { 'r' })
            {
                Category   = categoryOptional,
                IsOptional = true,
            };
            parser.Arguments.Add(_recursiveArgument);

            // --password, --pwd, -p
            _passwordArgument = new SwitchValueArgument <string>(
                "password",
                new ValueArgument <string>("password", "The password to use."),
                "Encrypts the package with a password.",
                new[] { "pwd" },
                new[] { 'p' })
            {
                Category   = categoryOptional,
                IsOptional = true,
            };
            parser.Arguments.Add(_passwordArgument);

            // --encryption, --enc, -e
            _encryptionArgument = new SwitchValueArgument <PackageEncryption>(
                "encryption",
                new EnumArgument <PackageEncryption>("method", "The default encryption method is ZipCrypto."),
                "Defines the encryption method in case a password is set.",
                new[] { "enc" },
                new[] { 'e' })
            {
                Category   = categoryOptional,
                IsOptional = true,
            };
            parser.Arguments.Add(_encryptionArgument);

            // --test, -t
            _testArgument = new SwitchArgument(
                "test",
                "Makes a test run without creating/updating the actual package.",
                null,
                new[] { 't' })
            {
                Category   = categoryOptional,
                IsOptional = true,
            };
            parser.Arguments.Add(_testArgument);

            // --help, -h, -?
            _helpArgument = new SwitchArgument(
                "help",
                "Shows help information.",
                null,
                new[] { 'h', '?' })
            {
                Category   = "Help",
                IsOptional = true,
            };
            parser.Arguments.Add(_helpArgument);

            return(parser);
        }
示例#14
0
        public void ParseInteger2()
        {
            var valueArg = new ValueArgument<int>("i", "") { AllowMultiple = false, IsOptional = true };
            var argument = new SwitchValueArgument<int>("Value", valueArg, "Description", null, new[] { 'v' })
            {
                Category = "Category",
                IsOptional = true,
            };

            int i = 0;
            string[] args = { "--value:1", "23", "4", "other" };
            var result = (ArgumentResult<int>)argument.Parse(args, ref i);
            Assert.AreEqual(1, i);
            Assert.AreEqual(1, result.Values.Count);
            Assert.AreEqual(1, result.Values[0]);
        }
示例#15
0
        private static CommandLineParser ConfigureCommandLine()
        {
            var parser = new CommandLineParser
            {
                AllowUnknownArguments = false,

                Description =
            @"This command-line tool can be used to pack files and directories into a single
            package. The resulting package file uses the ZIP format and can be read with
            standard ZIP tools.",

                HelpHeader =
            @"If no package exists at the target location, a new file is created.
            When the package already exists, it is updated.The input files are compared
            with the packaged files. New files are added, modified files are updated, and
            missing files are removed from the package. Files are compared by checking the
            ""Last Modified"" time and the file size.",

                HelpFooter =
            @"Credits
            -------
            Pack.exe - Copyright (C) 2014 DigitalRune GmbH. All rights reserved.
            DotNetZip - Copyright (C) 2006-2011 Dino Chiesa. All rights reserved.
            jzlib - Copyright (C) 2000-2003 ymnk, JCraft,Inc. All rights reserved.
            zlib - Copyright (C) 1995-2004 Jean-loup Gailly and Mark Adler."
            };

            var categoryMandatory = "Mandatory";
            var categoryOptional = "Optional";

            // ----- Mandatory arguments

            // Input files
            _inputArgument = new ValueArgument<string>(
                "files",
            @"Defines the files and directories to add to the package.
            The specified files and directories are relative to the current working copy or the base directory, which can be specified with /directory.
            Wildcards ('?', '*') are supported.")
            {
                Category = categoryMandatory,
                AllowMultiple = true,
            };
            parser.Arguments.Add(_inputArgument);

            // --output, --out, -o
            _outputArgument = new SwitchValueArgument<string>(
                "output",
                new ValueArgument<string>("package", "The filename incl. path of package."),
                "Defines the package to create or update.",
                new[] { "out" },
                new[] { 'o' })
            {
                Category = categoryMandatory,
            };
            parser.Arguments.Add(_outputArgument);

            // ----- Optional arguments

            // --directory, --dir, -d
            _directoryArgument = new SwitchValueArgument<string>(
                "directory",
                new ValueArgument<string>("directory", "The base directory."),
                "Specifies the base directory where to search for files.",
                new[] { "dir" },
                new[] { 'd' })
            {
                Category = categoryOptional,
                IsOptional = true,
            };
            parser.Arguments.Add(_directoryArgument);

            // --recursive, --rec, -r
            _recursiveArgument = new SwitchArgument(
                "recursive",
                "Adds subdirectories to package.",
                new[] { "rec" },
                new[] { 'r' })
            {
                Category = categoryOptional,
                IsOptional = true,
            };
            parser.Arguments.Add(_recursiveArgument);

            // --password, --pwd, -p
            _passwordArgument = new SwitchValueArgument<string>(
                "password",
                new ValueArgument<string>("password", "The password to use."),
                "Encrypts the package with a password.",
                new[] { "pwd" },
                new[] { 'p' })
            {
                Category = categoryOptional,
                IsOptional = true,
            };
            parser.Arguments.Add(_passwordArgument);

            // --encryption, --enc, -e
            _encryptionArgument = new SwitchValueArgument<PackageEncryption>(
                "encryption",
                new EnumArgument<PackageEncryption>("method", "The default encryption method is ZipCrypto."),
                "Defines the encryption method in case a password is set.",
                new[] { "enc" },
                new[] { 'e' })
            {
                Category = categoryOptional,
                IsOptional = true,
            };
            parser.Arguments.Add(_encryptionArgument);

            // --test, -t
            _testArgument = new SwitchArgument(
                "test",
                "Makes a test run without creating/updating the actual package.",
                null,
                new[] { 't' })
            {
                Category = categoryOptional,
                IsOptional = true,
            };
            parser.Arguments.Add(_testArgument);

            // --help, -h, -?
            _helpArgument = new SwitchArgument(
                "help",
                "Shows help information.",
                null,
                new[] { 'h', '?' })
            {
                Category = "Help",
                IsOptional = true,
            };
            parser.Arguments.Add(_helpArgument);

            return parser;
        }
示例#16
0
        static int Main(string[] args)
        {
            CommandLineParser parser = new CommandLineParser
            {
                AllowUnknownArguments = true,
            };

            parser.Description = "This is just a test application that demonstrates the usage of the CommandLineParser.";

            parser.HelpHeader =
                @"DESCRIPTION
    Here is a very detailed description of this app. Yadda, yadda, yadda...
    Yadda, yadda, yadda...
    Yadda, yadda, yadda...";

            parser.HelpFooter =
                @"EXAMPLES
    Show the help text:
        CommandLineApp --help
    
    Do something else:
        CommandLineApp --Enum Value1 Foo";

            var helpArgument = new SwitchArgument("help", "Show help.", null, new[] { 'h', '?' })
            {
                Category   = "Help",
                IsOptional = true,
            };

            parser.Arguments.Add(helpArgument);

            var fileArgument = new ValueArgument <string>("file", "The file to load.")
            {
                IsOptional    = false,
                AllowMultiple = true,
            };

            parser.Arguments.Add(fileArgument);

            var recursiveArgument = new SwitchArgument(
                "Recursive",
                "Enables recursive mode. \n This is just a demo text to test the formatting capabilities of the CommandLineParser.",
                null,
                new[] { 'R' })
            {
                IsOptional = true,
            };

            parser.Arguments.Add(recursiveArgument);

            var switchArgument1 = new SwitchArgument(
                "Switch1",
                "Another test switch. This is just a demo text to test the formatting capabilities of the CommandLineParser.")
            {
                Category   = "Test Category",
                IsOptional = true,
            };

            parser.Arguments.Add(switchArgument1);

            var switchArgument2 = new SwitchArgument(
                "Switch2",
                "Yet another test switch. This is just a demo text to test the formatting capabilities of the CommandLineParser. abcdefghijklmnopqrstuvw0123456789ABCDEFRGHIJKLMNOPQRSTUVWXYZ0123456789",
                null,
                new[] { 'S' })
            {
                Category   = "Test Category",
                IsOptional = true,
            };

            parser.Arguments.Add(switchArgument2);

            SwitchArgument longArgument = new SwitchArgument(
                "extremelyLongCommandLineArgumentToTestFormatting",
                "Extremely long argument. This is just a demo text to test the formatting capabilities of the CommandLineParser.",
                null,
                new[] { 'e' })
            {
                Category   = "Test Category",
                IsOptional = true,
            };

            parser.Arguments.Add(longArgument);

            var echoArgument = new SwitchValueArgument <string>(
                "echo",
                new ValueArgument <string>("text", null),
                "Prints the given text.")
            {
                Category   = null,
                IsOptional = true,
            };

            parser.Arguments.Add(echoArgument);

            var valueArgument = new SwitchValueArgument <int>(
                "value",
                new ValueArgument <int>("value", null)
            {
                AllowMultiple = true
            },
                "This switch has an integer value.",
                null,
                new[] { 'v' })
            {
                Category   = "Test Category 2",
                IsOptional = true,
            };

            parser.Arguments.Add(valueArgument);

            var boundedArgument = new SwitchValueArgument <float>(
                "bounded",
                new BoundedValueArgument <float>("boundedValue", null, 1, 5)
            {
                AllowMultiple = true, IsOptional = true
            },
                "This is a bounded integer value.",
                null,
                new[] { 'b' })
            {
                Category   = "Test Category 2",
                IsOptional = true,
            };

            parser.Arguments.Add(boundedArgument);

            var enumArgument = new SwitchValueArgument <MyEnum>(
                "Enum",
                new EnumArgument <MyEnum>("MyEnum", null)
            {
                IsOptional = true
            },
                "This is an enumeration.",
                null,
                new[] { 'e' })
            {
                Category   = "Test Category 2",
                IsOptional = true,
            };

            parser.Arguments.Add(enumArgument);

            var flagsArgument = new SwitchValueArgument <MyFlags>(
                "Flags",
                new EnumArgument <MyFlags>("MyFlags", "The value."),
                "This is a combination of flags (= enumeration with FlagsAttribute).",
                null,
                new[] { 'f' })
            {
                Category   = "Test Category 2",
                IsOptional = true,
            };

            parser.Arguments.Add(flagsArgument);

            ParseResult parseResult;

            try
            {
                parseResult = parser.Parse(args);

                if (parseResult.ParsedArguments[helpArgument] != null)
                {
                    // Show help and exit.
                    Console.WriteLine(parser.GetHelp());
                    return(ERROR_SUCCESS);
                }

                parser.ThrowIfMandatoryArgumentIsMissing(parseResult);
            }
            catch (CommandLineParserException exception)
            {
                Console.Error.WriteLine("ERROR");
                Console.Error.WriteLineIndented(exception.Message, 4);
                Console.Error.WriteLine();
                Console.Out.WriteLine("SYNTAX");
                Console.Out.WriteLineIndented(parser.GetSyntax(), 4);
                Console.Out.WriteLine();
                Console.Out.WriteLine("Try 'CommandLineApp --help'�for�more�information.");
                return(ERROR_BAD_ARGUMENTS);
            }

            var echo = parseResult.ParsedArguments["echo"] as ArgumentResult <string>;

            if (echo != null)
            {
                Console.Out.WriteLineWrapped(echo.Values[0]);
                return(ERROR_SUCCESS);
            }

            Console.WriteLine("----- Raw arguments");
            foreach (var arg in parseResult.RawArguments)
            {
                Console.WriteLine(arg);
            }

            Console.WriteLine();

            Console.WriteLine("----- Unknown arguments");
            foreach (var arg in parseResult.UnknownArguments)
            {
                Console.WriteLine(arg);
            }

            Console.WriteLine();

            Console.WriteLine("----- Parsed arguments");
            foreach (var arg in parseResult.ParsedArguments)
            {
                Console.Write("--");
                Console.Write(arg.Argument.Name);

                var values = arg.Values.Cast <object>().ToArray();

                if (values.Length > 0)
                {
                    Console.WriteLine(":");
                    foreach (var value in values)
                    {
                        Console.Write("    ");
                        Console.WriteLine(value);
                    }
                }
                else
                {
                    Console.WriteLine();
                }
            }

            return(ERROR_SUCCESS);
        }
示例#17
0
        static int Main(string[] args)
        {
            CommandLineParser parser = new CommandLineParser
            {
                AllowUnknownArguments = true,
            };

            parser.Description = "This is just a test application that demonstrates the usage of the CommandLineParser.";

            parser.HelpHeader =
            @"DESCRIPTION
            Here is a very detailed description of this app. Yadda, yadda, yadda...
            Yadda, yadda, yadda...
            Yadda, yadda, yadda...";

            parser.HelpFooter =
            @"EXAMPLES
            Show the help text:
            CommandLineApp --help

            Do something else:
            CommandLineApp --Enum Value1 Foo";

            var helpArgument = new SwitchArgument("help", "Show help.", null, new[] { 'h', '?' })
            {
                Category = "Help",
                IsOptional = true,
            };
            parser.Arguments.Add(helpArgument);

            var fileArgument = new ValueArgument<string>("file", "The file to load.")
            {
                IsOptional = false,
                AllowMultiple = true,
            };
            parser.Arguments.Add(fileArgument);

            var recursiveArgument = new SwitchArgument(
                "Recursive",
                "Enables recursive mode. \n This is just a demo text to test the formatting capabilities of the CommandLineParser.",
                null,
                new[] { 'R' })
            {
                IsOptional = true,
            };
            parser.Arguments.Add(recursiveArgument);

            var switchArgument1 = new SwitchArgument(
                "Switch1",
                "Another test switch. This is just a demo text to test the formatting capabilities of the CommandLineParser.")
            {
                Category = "Test Category",
                IsOptional = true,
            };
            parser.Arguments.Add(switchArgument1);

            var switchArgument2 = new SwitchArgument(
                "Switch2",
                "Yet another test switch. This is just a demo text to test the formatting capabilities of the CommandLineParser. abcdefghijklmnopqrstuvw0123456789ABCDEFRGHIJKLMNOPQRSTUVWXYZ0123456789",
                null,
                new[] { 'S' })
            {
                Category = "Test Category",
                IsOptional = true,
            };
            parser.Arguments.Add(switchArgument2);

            SwitchArgument longArgument = new SwitchArgument(
                "extremelyLongCommandLineArgumentToTestFormatting",
                "Extremely long argument. This is just a demo text to test the formatting capabilities of the CommandLineParser.",
                null,
                new[] { 'e' })
            {
                Category = "Test Category",
                IsOptional = true,
            };
            parser.Arguments.Add(longArgument);

            var echoArgument = new SwitchValueArgument<string>(
                "echo",
                new ValueArgument<string>("text", null),
                "Prints the given text.")
            {
                Category = null,
                IsOptional = true,
            };
            parser.Arguments.Add(echoArgument);

            var valueArgument = new SwitchValueArgument<int>(
                "value",
                new ValueArgument<int>("value", null) { AllowMultiple = true },
                "This switch has an integer value.",
                null,
                new[] { 'v' })
            {
                Category = "Test Category 2",
                IsOptional = true,
            };
            parser.Arguments.Add(valueArgument);

            var boundedArgument = new SwitchValueArgument<float>(
                "bounded",
                new BoundedValueArgument<float>("boundedValue", null, 1, 5) { AllowMultiple = true, IsOptional = true },
                "This is a bounded integer value.",
                null,
                new[] { 'b' })
            {
                Category = "Test Category 2",
                IsOptional = true,
            };
            parser.Arguments.Add(boundedArgument);

            var enumArgument = new SwitchValueArgument<MyEnum>(
                "Enum",
                new EnumArgument<MyEnum>("MyEnum", null) { IsOptional = true },
                "This is an enumeration.",
                null,
                new[] { 'e' })
            {
                Category = "Test Category 2",
                IsOptional = true,
            };
            parser.Arguments.Add(enumArgument);

            var flagsArgument = new SwitchValueArgument<MyFlags>(
                "Flags",
                new EnumArgument<MyFlags>("MyFlags", "The value."),
                "This is a combination of flags (= enumeration with FlagsAttribute).",
                null,
                new[] { 'f' })
            {
                Category = "Test Category 2",
                IsOptional = true,
            };
            parser.Arguments.Add(flagsArgument);

            ParseResult parseResult;
            try
            {
                parseResult = parser.Parse(args);

                if (parseResult.ParsedArguments[helpArgument] != null)
                {
                    // Show help and exit.
                    Console.WriteLine(parser.GetHelp());
                    return ERROR_SUCCESS;
                }

                parser.ThrowIfMandatoryArgumentIsMissing(parseResult);
            }
            catch (CommandLineParserException exception)
            {
                Console.Error.WriteLine("ERROR");
                Console.Error.WriteLineIndented(exception.Message, 4);
                Console.Error.WriteLine();
                Console.Out.WriteLine("SYNTAX");
                Console.Out.WriteLineIndented(parser.GetSyntax(), 4);
                Console.Out.WriteLine();
                Console.Out.WriteLine("Try 'CommandLineApp --help'�for�more�information.");
                return ERROR_BAD_ARGUMENTS;
            }

            var echo = parseResult.ParsedArguments["echo"] as ArgumentResult<string>;
            if (echo != null)
            {
                Console.Out.WriteLineWrapped(echo.Values[0]);
                return ERROR_SUCCESS;
            }

            Console.WriteLine("----- Raw arguments");
            foreach (var arg in parseResult.RawArguments)
                Console.WriteLine(arg);

            Console.WriteLine();

            Console.WriteLine("----- Unknown arguments");
            foreach (var arg in parseResult.UnknownArguments)
                Console.WriteLine(arg);

            Console.WriteLine();

            Console.WriteLine("----- Parsed arguments");
            foreach (var arg in parseResult.ParsedArguments)
            {
                Console.Write("--");
                Console.Write(arg.Argument.Name);

                var values = arg.Values.Cast<object>().ToArray();

                if (values.Length > 0)
                {
                    Console.WriteLine(":");
                    foreach (var value in values)
                    {
                        Console.Write("    ");
                        Console.WriteLine(value);
                    }
                }
                else
                {
                    Console.WriteLine();
                }
            }

            return ERROR_SUCCESS;
        }