/// <summary> /// Run GHACU logic on repository provided by user. /// </summary> /// <param name="repository">Path to repository.</param> /// <param name="shouldUpgrade">If true, actions will be updated, otherwise - just checking will be performed.</param> public void Run(string repository, bool shouldUpgrade) { IEnumerable <WorkflowInfo> infos; try { infos = _workflowService.GetWorkflows(repository); } catch (WorkflowValidationException e) { _streamer.Push <CliService>(new StreamOptions { Exception = e, Level = LogLevel.Error, Messages = new StreamMessageBuilder().Add(e.Message, ConsoleColor.Red).Build() }); return; } catch (Exception e) { _streamer.Push <CliService>(new StreamOptions { Exception = e, Level = LogLevel.Critical, Messages = new StreamMessageBuilder().Add(e.Message, ConsoleColor.DarkRed).Build() }); return; } IDictionary <WorkflowInfo, IEnumerable <GitHubAction> > outdated = _gitHubService.GetOutdated(infos); foreach ((WorkflowInfo wfi, IEnumerable <GitHubAction> actions) in outdated) { _printer.PrintHeader(wfi.Workflow.Name, wfi.File.Name); _printer.Print(actions); if (shouldUpgrade) { wfi.Upgrade(); } } if (!outdated.Any()) { _printer.PrintNoUpgradeNeeded(); } else if (!shouldUpgrade) { _streamer.PushEmpty(); _printer.PrintRunUpgrade(); } }