-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathProgram.cs
39 lines (33 loc) · 1.65 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
using Ookii.CommandLine;
namespace LongShort;
internal static class Program
{
// No need to use the Main(string[] args) overload (though you can if you want), because
// CommandLineParser can take the arguments directly from Environment.GetCommandLineArgs().
public static int Main()
{
// Parse the arguments. See ProgramArguments.cs for the definitions.
var arguments = ProgramArguments.Parse();
// No need to do anything when the value is null; Parse() already printed errors and
// usage to the console. We return a non-zero value to indicate failure.
if (arguments == null)
{
return 1;
}
// We use the LineWrappingTextWriter to neatly wrap console output.
using var writer = LineWrappingTextWriter.ForConsoleOut();
// Print the values of the arguments.
writer.WriteLine("The following argument values were provided:");
writer.WriteLine($"Source: {arguments.Source}");
writer.WriteLine($"Destination: {arguments.Destination}");
writer.WriteLine($"OperationIndex: {arguments.OperationIndex}");
writer.WriteLine($"Date: {arguments.Date?.ToString() ?? "(null)"}");
writer.WriteLine($"Count: {arguments.Count}");
writer.WriteLine($"Verbose: {arguments.Verbose}");
writer.WriteLine($"Process: {arguments.Process}");
var values = arguments.Values == null ? "(null)" : "{ " + string.Join(", ", arguments.Values) + " }";
writer.WriteLine($"Values: {values}");
writer.WriteLine($"Day: {arguments.Day?.ToString() ?? "(null)"}");
return 0;
}
}