-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathProgram.cs
86 lines (70 loc) · 3.64 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
using System;
using CommandLine;
using WaypointProcessor.Services;
namespace QuickStart
{
class Program
{
[Verb("duplicates", HelpText = "Find duplicates in 2 files")]
class DuplicatesOptions
{
[Option('b', "baseFileName", Required = true, HelpText = "Base file name")]
public required string BaseFileName { get; set; }
[Option('c', "comparedFileName", Required = true, HelpText = "Compared file name")]
public required string ComparedFileName { get; set; }
[Option('d', "distance", Required = false, HelpText = "Max distance to consider waypoints equal")]
public int Distance { get; set; } = 300;
}
[Verb("singleFileDuplicates", HelpText = "Find duplictes in a single file")]
class SingelFileDuplicatesOptions
{
[Option('b', "baseFileName", Required = true, HelpText = "Base file name")]
public required string BaseFileName { get; set; }
[Option('d', "distance", Required = false, HelpText = "Max distance to consider waypoints equal")]
public int Distance { get; set; } = 300;
}
[Verb("checkAltitudes", HelpText = "Check Altitudes against Public API")]
class CheckAltitudesOptions
{
[Option('b', "baseFileName", Required = true, HelpText = "Base file name")]
public required string BaseFileName { get; set; }
[Option('e', "errorDelta", Required = false, HelpText = "Max altitude difference to report an error")]
public int ErrorDelta { get; set; } = 50;
[Option('w', "warningDelta", Required = false, HelpText = "Max altitude difference to report a warning")]
public int WarningDelta { get; set; } = 50;
[Option('o', "output", Required = true, HelpText = "MarkDown file output path")]
public required string OutputFileName { get; set; }
[Option('v', "verbose", Required = false, HelpText = "Verbos mode: output all points = not just Err and Warn")]
public required bool IsVerbose { get; set; } = false;
}
static void Main(string[] args)
{
var program = new Program();
CommandLine.Parser.Default.ParseArguments<DuplicatesOptions, SingelFileDuplicatesOptions, CheckAltitudesOptions>(args)
.WithParsed<DuplicatesOptions>(program.RemoveDuplicates)
.WithParsed<SingelFileDuplicatesOptions>(program.RemoveSingleFileDuplicates)
.WithParsed<CheckAltitudesOptions>(program.CheckAltitudes)
.WithNotParsed(HandleParseError);
}
private static void HandleParseError(IEnumerable<Error> errs)
{
// Exit with error code
Environment.Exit(1);
}
private void RemoveDuplicates(DuplicatesOptions options)
{
var duplicatesFinderSercice = new DuplicatesFinderService(options.BaseFileName, options.Distance, options.ComparedFileName);
duplicatesFinderSercice.RemoveDuplicates();
}
private void RemoveSingleFileDuplicates(SingelFileDuplicatesOptions options)
{
var duplicatesFinderSercice = new DuplicatesFinderService(options.BaseFileName, options.Distance);
duplicatesFinderSercice.RemoveSingleFileDuplicates();
}
private void CheckAltitudes(CheckAltitudesOptions options)
{
var checkAltitudeService = new CheckAltitudeService(options.BaseFileName, options.ErrorDelta, options.WarningDelta, options.OutputFileName, options.IsVerbose);
checkAltitudeService.CheckAltitudes();
}
}
}