private static void LogErrorMessage(ProgramContext context, Exception ex) { var errorMessage = string.Format("Unexpected error occured: {0}", ex.Message); if (context.Log != null) { try { context.Log.Error(errorMessage); } catch { Console.WriteLine(errorMessage); } } else { Console.WriteLine(errorMessage); } var innerException = ex.InnerException; if (innerException != null) { LogErrorMessage(context, innerException); } }
public static int Main(string[] args) { var context = new ProgramContext { Args = args }; var steps = new ProgramSteps { new ParseInputStep(), new ShowLogoStep(), new ShowHelpStep(), new SetupWorkDirectoryStep(), new SetupLogRendererStep(), new AssertInputFileSetStep(), new SetupInputFileStep(), new InitializeWorkflowStep(), new ExecuteWorkflowStep() }; int result = steps.Execute(context); bool hold = context.Options != null && context.Options.Hold; DisposeLogRenderer(context); return Exit(hold, result); }
public int? Execute(ProgramContext context) { if (!context.Options.NoLogo) { Utils.ShowLogo(); } return null; }
public int? Execute(ProgramContext context) { if (context.Options.ShowHelp) { Utils.ShowHelp(context.OptionsConfig); return ExitCode.Ok; } return null; }
private static void DisplayLogoAndHelp(ProgramContext context) { try { Utils.ShowLogo(); Utils.ShowHelp(context.OptionsConfig); } catch (Exception e) { Console.WriteLine(e.Message); } }
public int? Execute(ProgramContext context) { if (context.Options.InputFile == null) { context.Log.Error("Input file path is not set"); Utils.ShowHelp(context.OptionsConfig); return ExitCode.Error.WrongInputFile; } return null; }
private static void DisposeLogRenderer(ProgramContext context) { if (context.LogRenderer != null) { try { context.LogRenderer.Dispose(); } catch (Exception ex) { Console.WriteLine("Error occured while disposing: {0}", ex.Message); } } }
public int? Execute(ProgramContext context) { ITaskResult<Nothing> result = ExecuteWorkflow( context.Workflow, context.Options.Tasks, context.LogRenderer, context.WorkDirectory); if (!result.IsSuccess) { return ExitCode.Error.WorkflowFailure; } return null; }
public int? Execute(ProgramContext context) { IFile inputFile = GetInputFile(context.Options, context.WorkDirectory); if (!inputFile.Exists) { context.Log.Error("Input file {0} does not exist!", inputFile.AbsolutePath); Utils.ShowHelp(context.OptionsConfig); return ExitCode.Error.WrongInputFile; } context.InputFile = inputFile; return null; }
public int? Execute(ProgramContext context) { var workDirectory = string.IsNullOrEmpty(context.Options.WorkDirectory) ? Directory.GetCurrentDirectory() : context.Options.WorkDirectory; if (!Path.IsPathRooted(workDirectory)) { workDirectory = Path.Combine(Directory.GetCurrentDirectory(), workDirectory); } Directory.SetCurrentDirectory(workDirectory); context.WorkDirectory = new DefaultDirectory(workDirectory); return null; }
public int? Execute(ProgramContext context) { InitializationResult initializationResult = InitializeWorkflow( context.Options, context.WorkDirectory, context.LogRenderer, context.InputFile); if (!initializationResult.IsSuccess) { return ExitCode.Error.RunnerInitializationFailure; } context.Workflow = initializationResult.Workflow; System.Console.WriteLine(); return null; }
public int? Execute(ProgramContext context) { try { context.Options = new RosaliaOptions(); context.OptionsConfig = RosaliaOptionsConfig.Create(context.Options); new OptionsParser().Parse(context.Args, context.OptionsConfig); if (context.Args.Length > 0) { context.Options.InputFile = context.Args[context.Args.Length - 1]; } } catch (Exception ex) { DisplayLogoAndHelp(context); throw new Exception("An error occured while parsing input arguments", ex); } return null; }
public int Execute(ProgramContext context) { for (int index = 0; index < _steps.Count; index++) { var step = _steps[index]; try { var stepResult = step.Execute(context); if (stepResult.HasValue) { return stepResult.Value; } } catch (Exception ex) { LogErrorMessage(context, ex); return GetStepErrorCode(index); } } return ExitCode.Ok; }
public int? Execute(ProgramContext context) { var logRenderers = new List<ILogRenderer> { new ColoredConsoleLogRenderer() }; foreach (var path in context.Options.OutputFiles) { var currentPath = path; if (Path.GetExtension(path).Equals(".html", StringComparison.InvariantCultureIgnoreCase)) { logRenderers.Add(new HtmlLogRenderer(new Lazy<TextWriter>(() => File.CreateText(currentPath)))); } } ILogRenderer logRenderer = new CompositeLogRenderer(logRenderers.ToArray()); context.LogRenderer = context.Options.LogLevel == null ? logRenderer : new FilterLogRenderer(logRenderer, context.Options.LogLevel.Value); context.LogRenderer.Init(); context.Log = new LogHelper(message => context.LogRenderer.Render(message, new Identities("Runner"))); return null; }