コード例 #1
0
        private bool ParseOption(string name, string value, CakeOptions options)
        {
            if (IsVerbosityOption(name))
            {
                Verbosity verbosity;
                if (!_verbosityParser.TryParse(value, out verbosity))
                {
                    verbosity        = Verbosity.Normal;
                    options.HasError = true;
                }
                options.Verbosity = verbosity;
            }

            if (IsShowDescriptionOption(name))
            {
                options.ShowDescription = ParseShowDescriptionOptionValue(value);
            }

            if (IsPerformDryRunOption(name))
            {
                options.PerformDryRun = ParsePerformDryRunOptionValue(value);
            }

            if (IsShowHelpOption(name))
            {
                options.ShowHelp = ParseShowHelpOptionValue(value);
            }

            if (name.Equals("version", StringComparison.OrdinalIgnoreCase) ||
                name.Equals("ver", StringComparison.OrdinalIgnoreCase))
            {
                options.ShowVersion = ParseBooleanValue(value);
            }

            if (name.Equals("debug", StringComparison.OrdinalIgnoreCase) ||
                name.Equals("d", StringComparison.OrdinalIgnoreCase))
            {
                options.PerformDebug = ParseBooleanValue(value);
            }

            if (name.Equals("mono", StringComparison.OrdinalIgnoreCase))
            {
                options.Mono = ParseBooleanValue(value);
            }

            if (name.Equals("bootstrap", StringComparison.OrdinalIgnoreCase))
            {
                options.Bootstrap = ParseBooleanValue(value);
            }

            if (options.Arguments.ContainsKey(name))
            {
                _log.Error("Multiple arguments with the same name ({0}).", name);
                return(false);
            }

            AddOptionToArgumentList(name, value, options);

            return(true);
        }
コード例 #2
0
        private bool ParseOption(string name, string value, CakeOptions options)
        {
            if (name.Equals("verbosity", StringComparison.OrdinalIgnoreCase) ||
                name.Equals("v", StringComparison.OrdinalIgnoreCase))
            {
                Verbosity verbosity;
                if (!_verbosityParser.TryParse(value, out verbosity))
                {
                    verbosity        = Verbosity.Normal;
                    options.HasError = true;
                }
                options.Verbosity = verbosity;
            }

            if (name.Equals("showdescription", StringComparison.OrdinalIgnoreCase) ||
                name.Equals("s", StringComparison.OrdinalIgnoreCase))
            {
                options.ShowDescription = ParseBooleanValue(value);
            }

            if (name.Equals("dryrun", StringComparison.OrdinalIgnoreCase) ||
                name.Equals("noop", StringComparison.OrdinalIgnoreCase) ||
                name.Equals("whatif", StringComparison.OrdinalIgnoreCase))
            {
                options.PerformDryRun = ParseBooleanValue(value);
            }

            if (name.Equals("help", StringComparison.OrdinalIgnoreCase) ||
                name.Equals("?", StringComparison.OrdinalIgnoreCase))
            {
                options.ShowHelp = ParseBooleanValue(value);
            }

            if (name.Equals("version", StringComparison.OrdinalIgnoreCase) ||
                name.Equals("ver", StringComparison.OrdinalIgnoreCase))
            {
                options.ShowVersion = ParseBooleanValue(value);
            }

            if (name.Equals("debug", StringComparison.OrdinalIgnoreCase) ||
                name.Equals("d", StringComparison.OrdinalIgnoreCase))
            {
                options.PerformDebug = ParseBooleanValue(value);
            }

            if (name.Equals("mono", StringComparison.OrdinalIgnoreCase))
            {
                options.Mono = ParseBooleanValue(value);
            }

            if (options.Arguments.ContainsKey(name))
            {
                _log.Error("Multiple arguments with the same name ({0}).", name);
                return(false);
            }

            options.Arguments.Add(name, value);
            return(true);
        }