/// <summary> /// Main program /// </summary> public async Task <int> Start() { // Show informational message and start-up diagnostics await ShowBanner().ConfigureAwait(false); // Version display (handled by ShowBanner in constructor) if (_args.Version) { await CloseDefault(); if (_args.CloseOnFinish) { return(0); } } // Help function if (_args.Help) { _arguments.ShowHelp(); await CloseDefault(); if (_args.CloseOnFinish) { return(0); } } // Main loop do { try { if (_args.Import) { await Import(RunLevel.Unattended); await CloseDefault(); } else if (_args.List) { await _renewalManager.ShowRenewalsUnattended(); await CloseDefault(); } else if (_args.Cancel) { await _renewalManager.CancelRenewalsUnattended(); await CloseDefault(); } else if (_args.Revoke) { await _renewalManager.RevokeCertificatesUnattended(); await CloseDefault(); } else if (_args.Renew) { var runLevel = RunLevel.Unattended; if (_args.Force) { runLevel |= RunLevel.ForceRenew | RunLevel.IgnoreCache; } await _renewalManager.CheckRenewals(runLevel); await CloseDefault(); } else if (!string.IsNullOrEmpty(_args.Target)) { await _renewalCreator.SetupRenewal(RunLevel.Unattended); await CloseDefault(); } else if (_args.Encrypt) { await Encrypt(RunLevel.Unattended); await CloseDefault(); } else if (_args.SetupTaskScheduler) { await _taskScheduler.CreateTaskScheduler(RunLevel.Unattended); await CloseDefault(); } else { await MainMenu(); } } catch (Exception ex) { _exceptionHandler.HandleException(ex); await CloseDefault(); } if (!_args.CloseOnFinish) { _args.Clear(); _exceptionHandler.ClearError(); _container.Resolve <IIISClient>().Refresh(); } }while (!_args.CloseOnFinish); // Return control to the caller _log.Verbose("Exiting with status code {code}", _exceptionHandler.ExitCode); return(_exceptionHandler.ExitCode); }
/// <summary> /// Main loop /// </summary> public async Task Start() { // Version display (handled by ShowBanner in constructor) if (_args.Version) { await CloseDefault(); if (_args.CloseOnFinish) { return; } } // Help function if (_args.Help) { _arguments.ShowHelp(); await CloseDefault(); if (_args.CloseOnFinish) { return; } } // Main loop do { try { if (_args.Import) { await Import(RunLevel.Unattended); await CloseDefault(); } else if (_args.List) { await _renewalManager.ShowRenewals(); await CloseDefault(); } else if (_args.Cancel) { await _renewalManager.CancelRenewal(RunLevel.Unattended); await CloseDefault(); } else if (_args.Renew) { var runLevel = RunLevel.Unattended; if (_args.Force) { runLevel |= RunLevel.ForceRenew | RunLevel.IgnoreCache; } await _renewalManager.CheckRenewals(runLevel); await CloseDefault(); } else if (!string.IsNullOrEmpty(_args.Target)) { await _renewalManager.SetupRenewal(RunLevel.Unattended); await CloseDefault(); } else if (_args.Encrypt) { await Encrypt(RunLevel.Unattended); await CloseDefault(); } else { await MainMenu(); } } catch (Exception ex) { _exceptionHandler.HandleException(ex); await CloseDefault(); } if (!_args.CloseOnFinish) { _args.Clear(); Environment.ExitCode = 0; _container.Resolve <IIISClient>().Refresh(); } else { _log.Verbose("Exiting with status code {code}", Environment.ExitCode); } }while (!_args.CloseOnFinish); }