Loading SimpleOCRCLI/SimpleOCRCLI/Helper/ProgramStarter.cs +4 −5 Original line number Diff line number Diff line Loading @@ -8,8 +8,7 @@ using Microsoft.Extensions.Logging; using GRYLibrary.Core.Logging.GRYLogger; using Error = CommandLine.Error; using SimpleOCR.CLI.Core.Verbs; using System; using SimpleOCR.CLI.Core.Runner; using GRYLibrary.Core.Logging.GeneralPurposeLogger; namespace SimpleOCR.CLI.Core.Helper { Loading @@ -24,7 +23,7 @@ namespace SimpleOCR.CLI.Core.Helper internal IVerbBaseVisitor<int>? VerbVisitor; public ProgramStarter() { this._Log = GRYLog.Create(); this._Log = GeneralLogger.CreateUsingConsole(); this.Version = GetVersion(); this.LicenseLink = $"https://projects.aniondev.de/PublicProjects/Common/SimpleOCR/v{this.Version}/License.txt"; this.BasicHelp = new List<string>() { Loading @@ -47,8 +46,8 @@ namespace SimpleOCR.CLI.Core.Helper { ParserResult<object> parserResult = Parser.Default.ParseArguments<DownloadOCRData, OCRAnalysis>(arguments); return parserResult.MapResult( (DownloadOCRData parsedArgument) => parsedArgument.Accept(new VerbVisitor()), (OCRAnalysis parsedArgument) => parsedArgument.Accept(new VerbVisitor()), (DownloadOCRData parsedArgument) => parsedArgument.Accept(new VerbVisitor(_Log)), (OCRAnalysis parsedArgument) => parsedArgument.Accept(new VerbVisitor(_Log)), errors => this.HandleErrors(errors, parserResult) ); } Loading SimpleOCRCLI/SimpleOCRCLI/Helper/VerbVisitor.cs +13 −3 Original line number Diff line number Diff line using SimpleOCR.CLI.Core.Runner; using SimpleOCR.CLI.Core.Verbs; using System; namespace SimpleOCR.CLI.Core.Helper { internal class VerbVisitor :IVerbBaseVisitor<int> { internal RunBase RunBase; public VerbVisitor() private readonly GRYLibrary.Core.Logging.GRYLogger.IGRYLog _Log; public VerbVisitor(GRYLibrary.Core.Logging.GRYLogger.IGRYLog log) { _Log = log; } public int Handle(OCRAnalysis runWithOptionsFromCLI) { this.RunBase = new RunOCRAnalysis(runWithOptionsFromCLI); this.RunBase = new RunOCRAnalysis(runWithOptionsFromCLI,_Log); Log(); return this.RunBase.Run(); } public int Handle(DownloadOCRData downloadOCRData) { this.RunBase = new RunDownloader(downloadOCRData); this.RunBase = new RunDownloader(downloadOCRData,_Log); Log(); return this.RunBase.Run(); } private void Log() { _Log.Log($"Starting {this.RunBase.GetType().Name}..."); } } } SimpleOCRCLI/SimpleOCRCLI/Properties/launchSettings.json +1 −1 Original line number Diff line number Diff line Loading @@ -3,7 +3,7 @@ "SimpleOCRCLI": { "commandName": "Project", //"commandLineArgs": "DownloadOCRData", //"commandLineArgs": "OCRAnalysis -l deu -f \"Somefile.pdf\"" //"commandLineArgs": "OCRAnalysis -l deu -f \"SomeFile.pdf\"", } } } No newline at end of file SimpleOCRCLI/SimpleOCRCLI/Runner/RunBase.cs +6 −2 Original line number Diff line number Diff line namespace SimpleOCR.CLI.Core.Runner using GRYLibrary.Core.Logging.GRYLogger; namespace SimpleOCR.CLI.Core.Runner { public abstract class RunBase { public string Result { get; private set; } protected RunBase() protected readonly IGRYLog _Log; protected RunBase(IGRYLog log) { this._Log = log; } public int Run() Loading SimpleOCRCLI/SimpleOCRCLI/Runner/RunDownloader.cs +3 −2 Original line number Diff line number Diff line using GRYLibrary.Core.Logging.GeneralPurposeLogger; using GRYLibrary.Core.Logging.GRYLogger; using SimpleOCR.CLI.Core.Misc; using SimpleOCR.CLI.Core.Verbs; Loading @@ -7,14 +8,14 @@ namespace SimpleOCR.CLI.Core.Runner internal class RunDownloader :RunBase { private readonly DownloadOCRData _Options; public RunDownloader(DownloadOCRData options) : base() public RunDownloader(DownloadOCRData options, IGRYLog log) : base(log) { this._Options = options; } protected override string RunImplementation() { SimpleOCR.Library.Core.IOCRService ocrService = new SimpleOCR.Library.Core.OCRService(new SimpleOCR.Library.Core.OCRServiceConfiguration() { DataFolder = Utilities.GetTargetFolder(_Options.TargetFolder) }, GeneralLogger.CreateUsingConsole()); SimpleOCR.Library.Core.IOCRService ocrService = new SimpleOCR.Library.Core.OCRService(new SimpleOCR.Library.Core.OCRServiceConfiguration() { DataFolder = Utilities.GetTargetFolder(_Options.TargetFolder) }, _Log); ocrService.DownloadOCRData(); return string.Empty; } Loading Loading
SimpleOCRCLI/SimpleOCRCLI/Helper/ProgramStarter.cs +4 −5 Original line number Diff line number Diff line Loading @@ -8,8 +8,7 @@ using Microsoft.Extensions.Logging; using GRYLibrary.Core.Logging.GRYLogger; using Error = CommandLine.Error; using SimpleOCR.CLI.Core.Verbs; using System; using SimpleOCR.CLI.Core.Runner; using GRYLibrary.Core.Logging.GeneralPurposeLogger; namespace SimpleOCR.CLI.Core.Helper { Loading @@ -24,7 +23,7 @@ namespace SimpleOCR.CLI.Core.Helper internal IVerbBaseVisitor<int>? VerbVisitor; public ProgramStarter() { this._Log = GRYLog.Create(); this._Log = GeneralLogger.CreateUsingConsole(); this.Version = GetVersion(); this.LicenseLink = $"https://projects.aniondev.de/PublicProjects/Common/SimpleOCR/v{this.Version}/License.txt"; this.BasicHelp = new List<string>() { Loading @@ -47,8 +46,8 @@ namespace SimpleOCR.CLI.Core.Helper { ParserResult<object> parserResult = Parser.Default.ParseArguments<DownloadOCRData, OCRAnalysis>(arguments); return parserResult.MapResult( (DownloadOCRData parsedArgument) => parsedArgument.Accept(new VerbVisitor()), (OCRAnalysis parsedArgument) => parsedArgument.Accept(new VerbVisitor()), (DownloadOCRData parsedArgument) => parsedArgument.Accept(new VerbVisitor(_Log)), (OCRAnalysis parsedArgument) => parsedArgument.Accept(new VerbVisitor(_Log)), errors => this.HandleErrors(errors, parserResult) ); } Loading
SimpleOCRCLI/SimpleOCRCLI/Helper/VerbVisitor.cs +13 −3 Original line number Diff line number Diff line using SimpleOCR.CLI.Core.Runner; using SimpleOCR.CLI.Core.Verbs; using System; namespace SimpleOCR.CLI.Core.Helper { internal class VerbVisitor :IVerbBaseVisitor<int> { internal RunBase RunBase; public VerbVisitor() private readonly GRYLibrary.Core.Logging.GRYLogger.IGRYLog _Log; public VerbVisitor(GRYLibrary.Core.Logging.GRYLogger.IGRYLog log) { _Log = log; } public int Handle(OCRAnalysis runWithOptionsFromCLI) { this.RunBase = new RunOCRAnalysis(runWithOptionsFromCLI); this.RunBase = new RunOCRAnalysis(runWithOptionsFromCLI,_Log); Log(); return this.RunBase.Run(); } public int Handle(DownloadOCRData downloadOCRData) { this.RunBase = new RunDownloader(downloadOCRData); this.RunBase = new RunDownloader(downloadOCRData,_Log); Log(); return this.RunBase.Run(); } private void Log() { _Log.Log($"Starting {this.RunBase.GetType().Name}..."); } } }
SimpleOCRCLI/SimpleOCRCLI/Properties/launchSettings.json +1 −1 Original line number Diff line number Diff line Loading @@ -3,7 +3,7 @@ "SimpleOCRCLI": { "commandName": "Project", //"commandLineArgs": "DownloadOCRData", //"commandLineArgs": "OCRAnalysis -l deu -f \"Somefile.pdf\"" //"commandLineArgs": "OCRAnalysis -l deu -f \"SomeFile.pdf\"", } } } No newline at end of file
SimpleOCRCLI/SimpleOCRCLI/Runner/RunBase.cs +6 −2 Original line number Diff line number Diff line namespace SimpleOCR.CLI.Core.Runner using GRYLibrary.Core.Logging.GRYLogger; namespace SimpleOCR.CLI.Core.Runner { public abstract class RunBase { public string Result { get; private set; } protected RunBase() protected readonly IGRYLog _Log; protected RunBase(IGRYLog log) { this._Log = log; } public int Run() Loading
SimpleOCRCLI/SimpleOCRCLI/Runner/RunDownloader.cs +3 −2 Original line number Diff line number Diff line using GRYLibrary.Core.Logging.GeneralPurposeLogger; using GRYLibrary.Core.Logging.GRYLogger; using SimpleOCR.CLI.Core.Misc; using SimpleOCR.CLI.Core.Verbs; Loading @@ -7,14 +8,14 @@ namespace SimpleOCR.CLI.Core.Runner internal class RunDownloader :RunBase { private readonly DownloadOCRData _Options; public RunDownloader(DownloadOCRData options) : base() public RunDownloader(DownloadOCRData options, IGRYLog log) : base(log) { this._Options = options; } protected override string RunImplementation() { SimpleOCR.Library.Core.IOCRService ocrService = new SimpleOCR.Library.Core.OCRService(new SimpleOCR.Library.Core.OCRServiceConfiguration() { DataFolder = Utilities.GetTargetFolder(_Options.TargetFolder) }, GeneralLogger.CreateUsingConsole()); SimpleOCR.Library.Core.IOCRService ocrService = new SimpleOCR.Library.Core.OCRService(new SimpleOCR.Library.Core.OCRServiceConfiguration() { DataFolder = Utilities.GetTargetFolder(_Options.TargetFolder) }, _Log); ocrService.DownloadOCRData(); return string.Empty; } Loading