public RunResult Run(string[] args) { var modelBuildResult = inputModelBuilderService.Build(args); if (!modelBuildResult.IsSuccess) { logger.LogInformation(@"Arguments: dictionary-file-name start-word end-word result-file"); logger.LogError(modelBuildResult.Error); return(RunResult.Failure(modelBuildResult.Error)); } var inputModel = modelBuildResult.InputModel; var runResult = RunEngine(inputModel); if (runResult.IsSuccess) { var outputPath = args[3]; runResult.FileSaveSuccessfully = SaveResultsToFile(runResult, outputPath); } return(runResult); }
private RunResult RunEngine(InputModel inputModel) { RunResult result = null; try { var wordSequence = engine.Run(inputModel, WordLength); logger.LogInformation("Successfully generated result file"); result = RunResult.Success(wordSequence); } catch (Exception ex) { result = RunResult.Failure(ex.Message); logger.LogError($"Unexpected error. Message: {ex.Message}"); } return(result); }