コード例 #1
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;
            }
        }