From 793fc0372533542be8c5fcf5b58ebdf540657eec Mon Sep 17 00:00:00 2001 From: Ryan Gregg Date: Mon, 22 Feb 2016 16:04:17 -0800 Subject: [PATCH] Add ability to ignore errors --- ApiDocs.Console/CommandLineOptions.cs | 3 +++ ApiDocs.Console/Program.cs | 11 +++++++++++ 2 files changed, 14 insertions(+) diff --git a/ApiDocs.Console/CommandLineOptions.cs b/ApiDocs.Console/CommandLineOptions.cs index 0ffdd81..75a6c7e 100644 --- a/ApiDocs.Console/CommandLineOptions.cs +++ b/ApiDocs.Console/CommandLineOptions.cs @@ -92,6 +92,9 @@ class BaseOptions [Option("appveyor-url", HelpText="Specify the AppVeyor Build Worker API URL for output integration")] public string AppVeyorServiceUrl { get; set; } + [Option("ignore-errors", HelpText="Prevent errors from generating a non-zero return code.")] + public bool IgnoreErrors { get; set; } + #if DEBUG [Option("debug", HelpText="Launch the debugger before doing anything interesting")] public bool AttachDebugger { get; set; } diff --git a/ApiDocs.Console/Program.cs b/ApiDocs.Console/Program.cs index 2319d2a..291c3e8 100644 --- a/ApiDocs.Console/Program.cs +++ b/ApiDocs.Console/Program.cs @@ -54,6 +54,9 @@ class Program public static readonly BuildWorkerApi BuildWorker = new BuildWorkerApi(); public static AppConfigFile CurrentConfiguration { get; private set; } + // Set to true to disable returning an error code when the app exits. + private static bool IgnoreErrors { get; set; } + static void Main(string[] args) { Logging.ProviderLogger(new ConsoleAppLogger()); @@ -80,6 +83,7 @@ static void Main(string[] args) Exit(failure: true); } + IgnoreErrors = verbOptions.IgnoreErrors; #if DEBUG if (verbOptions.AttachDebugger) { @@ -989,6 +993,13 @@ private static void Exit(bool failure, int? customExitCode = null) { exitCode = customExitCode.Value; } + + if (IgnoreErrors) + { + FancyConsole.WriteLine("Ignoring errors and returning a successful exit code."); + exitCode = ExitCodeSuccess; + } + #if DEBUG Console.WriteLine("Exit code: " + exitCode); if (Debugger.IsAttached)