/// <summary>
        /// Creates a new StringOption and adds it to the list of accepted options.
        /// </summary>
        /// <param name="shortForm">The optional short form for the option.</param>
        /// <param name="longForm">The long form for the option.</param>
        /// <returns>The newly created Option.</returns>
        /// <exception cref="System.ArgumentNullException">The long form is null.</exception>
        public StringOption AddStringOption(string shortForm, string longForm)
        {
            if (null == longForm)
            {
                throw new ArgumentNullException("longForm", "The long form is not optional.");
            }

            StringOption option = new StringOption(shortForm, longForm);

            AddOption((Option)option);
            return(option);
        }
Esempio n. 2
0
        /// <summary>
        /// Initializes a new instance of the Options class with the specified command
        /// line arguments.
        /// </summary>
        /// <param name="args">The arguments passed on the command line.</param>
        public Options(string[] args)
        {
            // Initialize the options
            _StartDateOption = new DateOption("s", "startdate");
            _BuildOption = new StringOption("b", "build", "Fixed");
            _PinOption = new StringOption("p", "pin", "0.0.0.0");
            _RevisionOption = new StringOption("r", "revision", "Automatic");
            _InputFile = new StringOption("i", "inputfile");
            _OutputFile = new StringOption("o", "outputfile");
            _Input = new StringOption("in", "input");
            _VersionOption = new StringOption("v", "version");

            // Create a new command line parser and add our options
            CmdLineParser parser = new CmdLineParser();
            parser.AddOption(_StartDateOption);
            parser.AddOption(_BuildOption);
            parser.AddOption(_PinOption);
            parser.AddOption(_RevisionOption);
            parser.AddOption(_InputFile);
            parser.AddOption(_OutputFile);
            parser.AddOption(_VersionOption);

            // Try to parse our options
            try
            {
                parser.Parse(args);
                ValidatePinOption();
            }
            catch(Exception)
            {
                throw;
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Creates a new StringOption and adds it to the list of accepted options.
        /// </summary>
        /// <param name="shortForm">The optional short form for the option.</param>
        /// <param name="longForm">The long form for the option.</param>
        /// <returns>The newly created Option.</returns>
        /// <exception cref="System.ArgumentNullException">The long form is null.</exception>
        public StringOption AddStringOption( string shortForm, string longForm )
        {
            if(null == longForm)
                throw new ArgumentNullException("longForm", "The long form is not optional.");

            StringOption option = new StringOption(shortForm, longForm);
            AddOption((Option)option);
            return option;
        }