private ICommand CreateCommand(CakeOptions options) { if (!options.HasError) { if (options.ShowHelp) { return(_commandFactory.CreateHelpCommand()); } if (options.ShowVersion) { return(_commandFactory.CreateVersionCommand()); } if (options.PerformDryRun) { return(_commandFactory.CreateDryRunCommand()); } if (options.ShowDescription) { return(_commandFactory.CreateDescriptionCommand()); } if (options.PerformDebug) { return(_commandFactory.CreateDebugCommand()); } return(_commandFactory.CreateBuildCommand()); } return(new ErrorCommandDecorator(_commandFactory.CreateHelpCommand())); }
/// <summary> /// Runs the application with the specified arguments. /// </summary> /// <param name="options">The options.</param> /// <returns>The application exit code.</returns> public int Run(CakeOptions options) { if (options == null) { throw new ArgumentNullException(nameof(options)); } // Create the correct command and execute it. var command = CreateCommand(options); var result = command.Execute(options); // Return success if the command succeeded. // If the parsed options are null, or if the command failed, consider it failed. return(result == false ? 1 : 0); }
private ICommand CreateCommand(CakeOptions options) { if (options != null) { if (options.ShowHelp) { return(_commandFactory.CreateHelpCommand()); } if (options.ShowVersion) { return(_commandFactory.CreateVersionCommand()); } if (options.Script != null) { if (options.PerformDryRun) { return(_commandFactory.CreateDryRunCommand()); } if (options.ShowDescription) { _log.SetVerbosity(options.Verbosity); return(_commandFactory.CreateDescriptionCommand()); } return(_commandFactory.CreateBuildCommand()); } } _console.WriteLine(); _log.Error("Could not find a build script to execute."); _log.Error("Either the first argument must the build script's path,"); _log.Error("or build script should follow default script name conventions."); return(new ErrorCommandDecorator(_commandFactory.CreateHelpCommand())); }
private ICommand CreateCommand(CakeOptions options) { if (options != null) { if (options.ShowHelp) { return(_commandFactory.CreateHelpCommand()); } if (options.ShowVersion) { return(_commandFactory.CreateVersionCommand()); } if (options.Script != null) { if (options.ShowDescription) { _log.Verbosity = Verbosity.Quiet; return(_commandFactory.CreateDescriptionCommand()); } return(_commandFactory.CreateBuildCommand()); } } return(_commandFactory.CreateHelpCommand()); }
/// <summary> /// Initializes a new instance of the <see cref="CakeArguments" /> class. /// </summary> /// <param name="options">The options.</param> public CakeArguments(CakeOptions options) { _arguments = new Dictionary <string, string>( (options ?? new CakeOptions()).Arguments ?? new Dictionary <string, string>(), StringComparer.OrdinalIgnoreCase); }