public async Task Execute(Arguments arguments, CancellationToken cancellationToken) { if (arguments is null) { _helpWriter.Write(); throw new FatalException("Arguments is null."); } if (arguments.IsVersion) { _versionWriter.Write(Assembly.GetExecutingAssembly()); return; } if (arguments.IsHelp) { _helpWriter.Write(); return; } // Configure Logging _log.AddLogAppender(new ConsoleAppender()); if (arguments.LogFilePath != null) { _log.AddLogAppender(new FileAppender(arguments.LogFilePath)); } if (!File.Exists(arguments.DacPacFilePath)) { throw new FatalException($"DacPac FilePath '{arguments.DacPacFilePath}' does not exist!", true); } // Continue with Deployment _log.Info("Using DacPac: {0}", arguments.DacPacFilePath); if (arguments.Threads == 0) { _log.Debug("Threads value was 0, so using default value of 1."); arguments.Threads = 1; } await _execCommand.Execute(cancellationToken); }
private bool HandleNonMainCommand(GitVersionOptions gitVersionOptions, out int exitCode) { if (gitVersionOptions == null) { helpWriter.Write(); exitCode = 1; return(true); } if (gitVersionOptions.IsVersion) { var assembly = Assembly.GetExecutingAssembly(); versionWriter.Write(assembly); exitCode = 0; return(true); } if (gitVersionOptions.IsHelp) { helpWriter.Write(); exitCode = 0; return(true); } if (gitVersionOptions.Diag) { gitVersionOptions.Settings.NoCache = true; gitVersionOptions.Output.Add(OutputType.BuildServer); } ConfigureLogging(gitVersionOptions, log); var workingDirectory = gitVersionOptions.WorkingDirectory; if (gitVersionOptions.Diag) { log.Info("Dumping commit graph: "); GitExtensions.DumpGraph(workingDirectory, mess => log.Info(mess), 100); } if (!Directory.Exists(workingDirectory)) { log.Warning($"The working directory '{workingDirectory}' does not exist."); } else { log.Info("Working directory: " + workingDirectory); } configFileLocator.Verify(gitVersionOptions, repositoryInfo); if (gitVersionOptions.Init) { configProvider.Init(workingDirectory); exitCode = 0; return(true); } if (gitVersionOptions.ConfigInfo.ShowConfig) { var config = configProvider.Provide(workingDirectory); console.WriteLine(config.ToString()); exitCode = 0; return(true); } exitCode = 0; return(false); }
private int VerifyArgumentsAndRun(Arguments arguments) { try { if (arguments == null) { helpWriter.Write(); return(1); } var targetPath = arguments.TargetPath; if (arguments.IsVersion) { var assembly = Assembly.GetExecutingAssembly(); versionWriter.Write(assembly); return(0); } if (arguments.IsHelp) { helpWriter.Write(); return(0); } if (arguments.Diag) { arguments.NoCache = true; arguments.Output = OutputType.BuildServer; } if (!string.IsNullOrEmpty(arguments.Proj) || !string.IsNullOrEmpty(arguments.Exec)) { arguments.Output = OutputType.BuildServer; } var buildServer = buildServerResolver.Resolve(); arguments.NoFetch = arguments.NoFetch || buildServer != null && buildServer.PreventFetch(); ConfigureLogging(arguments, log); if (arguments.Diag) { log.Info("Dumping commit graph: "); LibGitExtensions.DumpGraph(targetPath, mess => log.Info(mess), 100); } if (!Directory.Exists(targetPath)) { log.Warning($"The working directory '{targetPath}' does not exist."); } else { log.Info("Working directory: " + targetPath); } VerifyConfiguration(); if (arguments.Init) { configProvider.Init(targetPath); return(0); } if (arguments.ShowConfig) { var config = configProvider.Provide(targetPath); Console.WriteLine(config.ToString()); return(0); } execCommand.Execute(); } catch (WarningException exception) { var error = $"An error occurred:\r\n{exception.Message}"; log.Warning(error); return(1); } catch (Exception exception) { var error = $"An unexpected error occurred:\r\n{exception}"; log.Error(error); if (arguments == null) { return(1); } log.Info(string.Empty); log.Info("Attempting to show the current git graph (please include in issue): "); log.Info("Showing max of 100 commits"); try { LibGitExtensions.DumpGraph(arguments.TargetPath, mess => log.Info(mess), 100); } catch (Exception dumpGraphException) { log.Error("Couldn't dump the git graph due to the following error: " + dumpGraphException); } return(1); } return(0); }
private bool HandleNonMainCommand(Arguments arguments, out int exitCode) { if (arguments == null) { helpWriter.Write(); exitCode = 1; return(true); } var targetPath = arguments.TargetPath; if (arguments.IsVersion) { var assembly = Assembly.GetExecutingAssembly(); versionWriter.Write(assembly); exitCode = 0; return(true); } if (arguments.IsHelp) { helpWriter.Write(); exitCode = 0; return(true); } if (arguments.Diag) { arguments.NoCache = true; arguments.Output.Add(OutputType.BuildServer); } #pragma warning disable CS0612 // Type or member is obsolete if (!string.IsNullOrEmpty(arguments.Proj) || !string.IsNullOrEmpty(arguments.Exec)) #pragma warning restore CS0612 // Type or member is obsolete { arguments.Output.Add(OutputType.BuildServer); } var buildServer = buildServerResolver.Resolve(); arguments.NoFetch = arguments.NoFetch || buildServer != null && buildServer.PreventFetch(); ConfigureLogging(arguments, log); if (arguments.Diag) { log.Info("Dumping commit graph: "); LibGitExtensions.DumpGraph(targetPath, mess => log.Info(mess), 100); } if (!Directory.Exists(targetPath)) { log.Warning($"The working directory '{targetPath}' does not exist."); } else { log.Info("Working directory: " + targetPath); } configFileLocator.Verify(gitPreparer); if (arguments.Init) { configProvider.Init(targetPath); exitCode = 0; return(true); } if (arguments.ShowConfig) { var config = configProvider.Provide(targetPath); Console.WriteLine(config.ToString()); exitCode = 0; return(true); } exitCode = 0; return(false); }
private int VerifyArgumentsAndRun(Arguments arguments) { try { if (arguments == null) { helpWriter.Write(); return(1); } if (arguments.IsVersion) { var assembly = Assembly.GetExecutingAssembly(); versionWriter.Write(assembly); return(0); } if (arguments.IsHelp) { helpWriter.Write(); return(0); } if (arguments.Diag) { arguments.NoCache = true; arguments.Output = OutputType.BuildServer; } if (!string.IsNullOrEmpty(arguments.Proj) || !string.IsNullOrEmpty(arguments.Exec)) { arguments.Output = OutputType.BuildServer; } ConfigureLogging(arguments, log); if (arguments.Diag) { log.Info("Dumping commit graph: "); LibGitExtensions.DumpGraph(arguments.TargetPath, mess => log.Info(mess), 100); } if (!Directory.Exists(arguments.TargetPath)) { log.Warning($"The working directory '{arguments.TargetPath}' does not exist."); } else { log.Info("Working directory: " + arguments.TargetPath); } VerifyConfiguration(arguments); if (arguments.Init) { ConfigurationProvider.Init(arguments.TargetPath, fileSystem, new ConsoleAdapter(), log, configFileLocator); return(0); } if (arguments.ShowConfig) { Console.WriteLine(ConfigurationProvider.GetEffectiveConfigAsString(arguments.TargetPath, configFileLocator)); return(0); } var execCommand = new ExecCommand(); execCommand.Execute(arguments, fileSystem, environment, log, configFileLocator); } catch (WarningException exception) { var error = $"An error occurred:\r\n{exception.Message}"; log.Warning(error); return(1); } catch (Exception exception) { var error = $"An unexpected error occurred:\r\n{exception}"; log.Error(error); if (arguments == null) { return(1); } log.Info(string.Empty); log.Info("Attempting to show the current git graph (please include in issue): "); log.Info("Showing max of 100 commits"); try { LibGitExtensions.DumpGraph(arguments.TargetPath, mess => log.Info(mess), 100); } catch (Exception dumpGraphException) { log.Error("Couldn't dump the git graph due to the following error: " + dumpGraphException); } return(1); } return(0); }