org.GraphDefined.Vanaheimr.Illias.CommandLineParser.AddOption C# (CSharp) Method

AddOption() public method

Create a new fluent interface to create command line parser options.
public AddOption ( ) : CommandLineParserOption
return CommandLineParserOption
        public CommandLineParserOption AddOption()
        {
            return new CommandLineParserOption(this);
        }

Same methods

CommandLineParser::AddOption ( Char ShortOption, Action Delegate, String Verification = null ) : CommandLineParser
CommandLineParser::AddOption ( Char ShortOption, String LongOption, Action Delegate, String Verification = null ) : CommandLineParser
CommandLineParser::AddOption ( String LongOption, Action Delegate, String Verification = null ) : CommandLineParser

Usage Example

Ejemplo n.º 1
0
        /// <summary>
        /// Apply/store this command line parser option.
        /// </summary>
        /// <returns></returns>
        public CommandLineParser Apply()
        {
            if (!_Short.HasValue && LongOption == null)
            {
                throw new ArgumentException("Either a short or long option must be defined!");
            }

            if (Action == null)
            {
                throw new ArgumentException("An action has to be defined for this option!");
            }

            if (_Short.HasValue)
            {
                CommandLineParser.AddOption(_Short.Value, Action);
            }

            if (LongOption != null)
            {
                CommandLineParser.AddOption(LongOption, Action);
            }

            return(CommandLineParser);
        }