public async Task Run() { var caseInsensitiveParser = new Parser(with => { with.CaseSensitive = false; with.IgnoreUnknownArguments = false; with.HelpWriter = Console.Out; with.AutoVersion = true; with.AutoHelp = true; }); try { var result = caseInsensitiveParser.ParseArguments <ExtractorOptions>(commandLineArguments); result .WithParsed(options => this.options = options) .WithNotParsed(errors => errors.ToList().ForEach(e => errorMessages.Add(e.ToString()))); } catch (Exception ex) { errorMessages.Add(ex.Message); } if (errorMessages.Any()) { Environment.Exit(SignalInvalidOptions); } var exitCode = await PerformUnzip(options); Environment.Exit(exitCode); }
private async Task <int> PerformUnzip(ExtractorOptions options) { try { var sourceFiles = EnumerateSourceFiles(options.SourcePath); await UnzipFiles(sourceFiles); return(SignalSuccess); } catch (Exception ex) { errorMessages.Add(ex.Message); return(SignalExtractionFailed); } }