private bool ParseOption(string arg, CakeOptions options) { string name, value; var separatorIndex = arg.IndexOfAny(new[] { '=' }); if (separatorIndex < 0) { name = arg.Substring(1); value = string.Empty; } else { name = arg.Substring(1, separatorIndex - 1); value = arg.Substring(separatorIndex + 1); } if (value.Length > 2) { if (value[0] == '\"' && value[value.Length - 1] == '\"') { value = value.Substring(1, value.Length - 2); } } return(ParseOption(name, value, options)); }
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); }
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); }
private CakeOptions BuildDefaultOptions() { var options = new CakeOptions(); SetDefaultOptions(options); return(options); }
public CakeOptions Parse(IEnumerable <string> args) { if (args == null) { throw new ArgumentNullException("args"); } var options = new CakeOptions(); var isParsingOptions = false; foreach (var arg in args) { var value = arg.UnQuote(); if (isParsingOptions) { if (IsOption(value)) { if (!ParseOption(value, options)) { return(null); } } else { _log.Error("More than one build script specified."); return(null); } } else { try { if (IsOption(arg)) { _log.Error("First argument must be the build script."); return(null); } // Quoted? options.Script = new FilePath(value); } finally { // Start parsing options. isParsingOptions = true; } } } return(options); }
private bool ParseOption(string name, string value, CakeOptions options) { if (name.Equals("verbosity", StringComparison.OrdinalIgnoreCase) || name.Equals("v", StringComparison.OrdinalIgnoreCase)) { // Parse verbosity. var converter = TypeDescriptor.GetConverter(typeof(Verbosity)); var verbosity = converter.ConvertFromInvariantString(value); if (verbosity != null) { options.Verbosity = (Verbosity)verbosity; } } if (name.Equals("showdescription", StringComparison.OrdinalIgnoreCase) || name.Equals("s", StringComparison.OrdinalIgnoreCase)) { options.ShowDescription = true; } if (name.Equals("dryrun", StringComparison.OrdinalIgnoreCase) || name.Equals("noop", StringComparison.OrdinalIgnoreCase) || name.Equals("whatif", StringComparison.OrdinalIgnoreCase)) { options.PerformDryRun = true; } if (name.Equals("help", StringComparison.OrdinalIgnoreCase) || name.Equals("?", StringComparison.OrdinalIgnoreCase)) { options.ShowHelp = true; } if (name.Equals("version", StringComparison.OrdinalIgnoreCase) || name.Equals("ver", StringComparison.OrdinalIgnoreCase)) { options.ShowVersion = true; } if (options.Arguments.ContainsKey(name)) { _log.Error("Multiple arguments with the same name ({0}).", name); return(false); } options.Arguments.Add(name, value); return(true); }
private bool ParseOption(string name, string value, CakeOptions options) { if (name.Equals("verbosity", StringComparison.OrdinalIgnoreCase) || name.Equals("v", StringComparison.OrdinalIgnoreCase)) { // Parse verbosity. options.Verbosity = _verbosityParser.Parse(value); } if (name.Equals("showdescription", StringComparison.OrdinalIgnoreCase) || name.Equals("s", StringComparison.OrdinalIgnoreCase)) { options.ShowDescription = true; } if (name.Equals("dryrun", StringComparison.OrdinalIgnoreCase) || name.Equals("noop", StringComparison.OrdinalIgnoreCase) || name.Equals("whatif", StringComparison.OrdinalIgnoreCase)) { options.PerformDryRun = true; } if (name.Equals("help", StringComparison.OrdinalIgnoreCase) || name.Equals("?", StringComparison.OrdinalIgnoreCase)) { options.ShowHelp = true; } if (name.Equals("version", StringComparison.OrdinalIgnoreCase) || name.Equals("ver", StringComparison.OrdinalIgnoreCase)) { options.ShowVersion = true; } if (options.Arguments.ContainsKey(name)) { _log.Error("Multiple arguments with the same name ({0}).", name); return(false); } options.Arguments.Add(name, value); return(true); }
private bool ParseOption(string arg, CakeOptions options) { string name, value; var nameIndex = arg.StartsWith("--") ? 2 : 1; var separatorIndex = arg.IndexOfAny(new[] { '=' }); if (separatorIndex < 0) { name = arg.Substring(nameIndex); value = string.Empty; } else { name = arg.Substring(nameIndex, separatorIndex - nameIndex); value = arg.Substring(separatorIndex + 1); } return(ParseOption(name, value.UnQuote(), options)); }
public CakeOptions Parse(IEnumerable <string> args) { if (args == null) { throw new ArgumentNullException("args"); } var options = new CakeOptions(); var isParsingOptions = false; var arguments = args.ToList(); if (arguments.Count == 0) { // If we don't have any arguments, set a default script. options.Script = "./build.cake"; } foreach (var arg in arguments) { var value = arg.UnQuote(); if (isParsingOptions) { if (IsOption(value)) { if (!ParseOption(value, options)) { options.HasError = true; return(options); } } else { _log.Error("More than one build script specified."); options.HasError = true; return(options); } } else { try { // If they didn't provide a specific build script, search for a default. if (IsOption(arg)) { // Make sure we parse the option if (!ParseOption(value, options)) { options.HasError = true; return(options); } options.Script = "./build.cake"; continue; } // Quoted? options.Script = new FilePath(value); } finally { // Start parsing options. isParsingOptions = true; } } } return(options); }
private void AddOptionToArgumentList(string name, string value, CakeOptions options) { options.Arguments.Add(name, value); }
public CakeOptions Parse(IEnumerable <string> args) { if (args == null) { throw new ArgumentNullException(nameof(args)); } var options = new CakeOptions(); var isParsingOptions = false; var arguments = args.ToList(); if (NoUserArguments(arguments)) { return(BuildDefaultOptions()); } foreach (var argument in arguments) { var value = argument.UnQuote(); if (isParsingOptions) { if (IsOption(value)) { if (!ParseOption(value, options)) { options.HasError = true; return(options); } } else { _log.Error("More than one build script specified."); options.HasError = true; return(options); } } else { try { // If they didn't provide a specific build script, search for a default. if (IsOption(argument)) { // Make sure we parse the option if (!ParseOption(value, options)) { options.HasError = true; return(options); } options.Script = DefaultScriptFilePath; continue; } // Quoted? options.Script = new FilePath(value); } finally { // Start parsing options. isParsingOptions = true; } } } return(options); }
private void SetDefaultScript(CakeOptions options) { options.Script = DefaultScriptFilePath; }
private void SetDefaultOptions(CakeOptions options) { SetDefaultScript(options); }
public CakeOptions Parse(IEnumerable<string> args) { if (args == null) { throw new ArgumentNullException("args"); } var options = new CakeOptions(); var isParsingOptions = false; var arguments = args.ToList(); // If we don't have any arguments, search for a default script. if (arguments.Count == 0) { options.Script = GetDefaultScript(); } foreach (var arg in arguments) { var value = arg.UnQuote(); if (isParsingOptions) { if (IsOption(value)) { if (!ParseOption(value, options)) { return null; } } else { _log.Error("More than one build script specified."); return null; } } else { try { // If they didn't provide a specific build script, search for a defualt. if (IsOption(arg)) { // Make sure we parse the option if (!ParseOption(value, options)) { return null; } options.Script = GetDefaultScript(); continue; } // Quoted? options.Script = value; } finally { // Start parsing options. isParsingOptions = true; } } } return options; }
private bool ParseOption(string name, string value, CakeOptions options) { if (name.Equals("verbosity", StringComparison.OrdinalIgnoreCase) || name.Equals("v", StringComparison.OrdinalIgnoreCase)) { // Parse verbosity. var converter = TypeDescriptor.GetConverter(typeof(Verbosity)); var verbosity = converter.ConvertFromInvariantString(value); if (verbosity != null) { options.Verbosity = (Verbosity)verbosity; } } if (name.Equals("showdescription", StringComparison.OrdinalIgnoreCase) || name.Equals("s", StringComparison.OrdinalIgnoreCase)) { options.ShowDescription = true; } if (name.Equals("dryrun", StringComparison.OrdinalIgnoreCase) || name.Equals("noop", StringComparison.OrdinalIgnoreCase) || name.Equals("whatif", StringComparison.OrdinalIgnoreCase)) { options.PerformDryRun = true; } if (name.Equals("help", StringComparison.OrdinalIgnoreCase) || name.Equals("?", StringComparison.OrdinalIgnoreCase)) { options.ShowHelp = true; } if (name.Equals("version", StringComparison.OrdinalIgnoreCase) || name.Equals("ver", StringComparison.OrdinalIgnoreCase)) { options.ShowVersion = true; } if (options.Arguments.ContainsKey(name)) { _log.Error("Multiple arguments with the same name ({0}).", name); return false; } options.Arguments.Add(name, value); return true; }
private bool ParseOption(string arg, CakeOptions options) { string name, value; var separatorIndex = arg.IndexOfAny(new[] { '=' }); if (separatorIndex < 0) { name = arg.Substring(1); value = string.Empty; } else { name = arg.Substring(1, separatorIndex - 1); value = arg.Substring(separatorIndex + 1); } if (value.Length > 2) { if (value[0] == '\"' && value[value.Length - 1] == '\"') { value = value.Substring(1, value.Length - 2); } } return ParseOption(name, value, options); }