Skip to content

Commit

Permalink
https://github.com/OnlyFart/Elib2Ebook/issues/124
Browse files Browse the repository at this point in the history
  • Loading branch information
OnlyFart committed Oct 20, 2024
1 parent 0a598f1 commit c3ddadf
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 15 deletions.
1 change: 0 additions & 1 deletion Elib2EbookCli/Elib2EbookCli.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
</PropertyGroup>

<ItemGroup>
Expand Down
38 changes: 24 additions & 14 deletions Elib2EbookCli/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System.Text;
using System.Diagnostics;
using System.Reflection;
using System.Text;
using CommandLine;
using CommandLine.Text;
using Core.Configs;
Expand All @@ -10,28 +12,36 @@
namespace Elib2EbookCli;

internal static class Program {

private static async Task Main(string[] args) {
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
Console.OutputEncoding = Encoding.UTF8;

var logger = new ConsoleLogger();

var parserResult = new Parser(with => with.CaseInsensitiveEnumValues = true).ParseArguments<Options>(args);
var parserResult = new Parser(c => {
c.CaseInsensitiveEnumValues = true;
}).ParseArguments<Options>(args);


await parserResult
.WithNotParsed(errors => {
var sentenceBuilder = SentenceBuilder.Create();
foreach (var error in errors) {
logger.LogInformation(sentenceBuilder.FormatError(error));
}
.WithNotParsed(errs => {
var title = Assembly.GetEntryAssembly().GetName();

Check warning on line 29 in Elib2EbookCli/Program.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Dereference of a possibly null reference.

Check warning on line 29 in Elib2EbookCli/Program.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Dereference of a possibly null reference.

Check warning on line 29 in Elib2EbookCli/Program.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Dereference of a possibly null reference.

Check warning on line 29 in Elib2EbookCli/Program.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

Dereference of a possibly null reference.

Check warning on line 29 in Elib2EbookCli/Program.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

Dereference of a possibly null reference.

Check warning on line 29 in Elib2EbookCli/Program.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

Dereference of a possibly null reference.

Check warning on line 29 in Elib2EbookCli/Program.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

Dereference of a possibly null reference.

Check warning on line 29 in Elib2EbookCli/Program.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

Dereference of a possibly null reference.

Check warning on line 29 in Elib2EbookCli/Program.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

Dereference of a possibly null reference.
var version = FileVersionInfo.GetVersionInfo("Core.dll").ProductVersion.Split("+")[0];

Check warning on line 30 in Elib2EbookCli/Program.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Dereference of a possibly null reference.

Check warning on line 30 in Elib2EbookCli/Program.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Dereference of a possibly null reference.

Check warning on line 30 in Elib2EbookCli/Program.cs

View workflow job for this annotation

GitHub Actions / build (ubuntu-latest)

Dereference of a possibly null reference.

Check warning on line 30 in Elib2EbookCli/Program.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

Dereference of a possibly null reference.

Check warning on line 30 in Elib2EbookCli/Program.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

Dereference of a possibly null reference.

Check warning on line 30 in Elib2EbookCli/Program.cs

View workflow job for this annotation

GitHub Actions / build (macos-latest)

Dereference of a possibly null reference.

Check warning on line 30 in Elib2EbookCli/Program.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

Dereference of a possibly null reference.

Check warning on line 30 in Elib2EbookCli/Program.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

Dereference of a possibly null reference.

Check warning on line 30 in Elib2EbookCli/Program.cs

View workflow job for this annotation

GitHub Actions / build (windows-latest)

Dereference of a possibly null reference.

var helpText = HelpText.AutoBuild(parserResult, h => {
h.Heading = string.Empty; //change header
h.Copyright = string.Empty; //change copyright text
return h;
}, e => e);

logger.LogInformation(helpText);
var heading = new HeadingInfo(title.Name, version);

if (errs.IsVersion()) {
logger.LogInformation(heading);
} else {
var helpText = HelpText.AutoBuild(parserResult, h => {
h.Heading = heading;
h.Copyright = string.Empty;
return h;
});

logger.LogInformation(helpText);
}
})
.WithParsedAsync(async options => {
using var getterConfig = BookGetterConfig.GetDefault(options, logger);
Expand Down

0 comments on commit c3ddadf

Please sign in to comment.