/// <summary>
        /// Configure command options and describe details in the class contructor
        /// </summary>
        /// <example>
        /// Example usage:
        ///
        /// SampleConsole.exe example "option one" two -b -o "optional argument" -l=first -l=second -l "the third option"
        ///
        /// Expected output:
        ///
        /// Executing Example (Example implementation of a ManyConsole command-line argument
        /// parser Command):
        ///    Argument1 : option one
        ///    Argument2 : two
        ///    BooleanOption : True
        ///    OptionalArgument1 : optional argument
        ///    OptionalArgumentList : System.Collections.Generic.List`1[System.String]
        ///
        ///Called Example command - Argument1 = "option one" Argument2 = "two" BooleanOptio
        ///n: True
        ///List Item 0 = "first"
        ///List Item 1 = "second"
        ///List Item 2 = "the third option"
        /// </example>
        public ExampleCommand()
        {
            this.IsCommand("Example", "Example implementation of a ManyConsole command-line argument parser Command");

            this.HasOption("b|booleanOption", "Boolean flag option", b => BooleanOption = true);


            this.HasOption("l|list=", "Values to add to list", v => OptionalArgumentList.Add(v));


            this.HasRequiredOption("requiredOption=", "Required string argument also requiring a value.", s => { });
            this.HasOption("anotherOptional=", "Another way to specify optional arguments", s => {});

            HasAdditionalArguments(2, "<Argument1> <Argument2>");
        }
示例#2
0
        /// <summary>
        /// Configure command options and describe details in the class contructor
        /// </summary>
        /// <example>
        /// Example usage:
        ///
        /// SampleConsole.exe example "option one" two -b -o "optional argument" -l=first -l=second -l "the third option"
        ///
        /// Expected output:
        ///
        /// Executing Example (Example implementation of a ManyConsole command-line argument
        /// parser Command):
        ///    Argument1 : option one
        ///    Argument2 : two
        ///    BooleanOption : True
        ///    OptionalArgument1 : optional argument
        ///    OptionalArgumentList : System.Collections.Generic.List`1[System.String]
        ///
        ///Called Example command - Argument1 = "option one" Argument2 = "two" BooleanOptio
        ///n: True
        ///List Item 0 = "first"
        ///List Item 1 = "second"
        ///List Item 2 = "the third option"
        /// </example>
        public Example()
        {
            this.IsCommand("Example", "Example implementation of a ManyConsole command-line argument parser Command");

            Options = new OptionSet()
            {
                { "b|booleanOption", "Boolean flag option", b => BooleanOption = true },
                { "l|list=", "Values to add to list", v => OptionalArgumentList.Add(v) },
                { "r|requiredArguments=", "Optional string argument requiring a value be specified afterwards", s => OptionalArgument1 = s },
                { "o|optionalArgument:", "Optional String argument which is null if no value follow is specified", s => OptionalArgument2 = s ?? "<no argument specified>" }
            };

            this.HasRequiredOption("requiredOption=", "Required string argument also requiring a value.", s => { });
            this.HasOption("anotherOptional=", "Another way to specify optional arguments", s => {});

            HasAdditionalArguments(2, "<Argument1> <Argument2>");
        }