-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathProgram.cs
47 lines (40 loc) · 1.74 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
using CommandLine;
using CommandLine.Text;
using NetAmermaid;
const string asciiHeading = @"
/\ .
/ _ / | .-. /
. .-. .-.---/---( / | .. .-. .-. .-. ).--.. .-. .-. .-. `-'.-../
)/ )./.-'_ / `/.__|_.' )/ ) )./.-'_/ )/ ) )( | / ( /
'/ ( (__.' / .:' / | '/ / ( (__.'/ '/ / ( `-'-'_.(__. `-'-..
`- (__.' `-' `-' `-'
"; // from http://www.patorjk.com/software/taag/#p=display&f=Diet%20Cola&t=netAmermaid
try
{
// set HelpWriter null to enable customizing help text, see below
ParserResult<GenerateHtmlDiagrammer> parserResult = new Parser(with => with.HelpWriter = null).ParseArguments<GenerateHtmlDiagrammer>(args);
parserResult.WithParsed(command =>
{
command.Run();
Environment.ExitCode = (int)ExitCodes.Success;
});
parserResult.WithNotParsed(errors => Console.WriteLine(HelpText.AutoBuild(parserResult, h =>
{
h.Heading = asciiHeading + h.Heading; // enhance heading for branding
Environment.ExitCode = (int)ExitCodes.Error;
// see https://learn.microsoft.com/en-us/dotnet/api/system.console.windowwidth?view=net-8.0#remarks
if (!Console.IsOutputRedirected) h.MaximumDisplayWidth = Console.WindowWidth;
h.AddPostOptionsLine($"See {GenerateHtmlDiagrammer.RepoUrl} for more info.");
return h;
})));
}
catch (Exception ex)
{
Console.Error.WriteLine(ex.ToString());
Environment.ExitCode = (int)ExitCodes.Error;
}
public enum ExitCodes
{
Error = -1,
Success = 0
}