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

AddOption() public method

Add the given action for the given character, e.g. "o" for a "-o" command line option.
public AddOption ( Char ShortOption, Action Delegate, String Verification = null ) : CommandLineParser
ShortOption Char A short option.
Delegate Action What to do with the value of the character option.
Verification String An optional regular expression for verification.
return CommandLineParser
        public CommandLineParser AddOption(Char ShortOption, Action<String> Delegate, String Verification = null)
        {
            ShortOptions.Add(ShortOption, Delegate);
            return this;
        }

Same methods

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

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);
        }