-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
41 lines (37 loc) · 1.28 KB
/
Copy pathProgram.cs
File metadata and controls
41 lines (37 loc) · 1.28 KB
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
internal static class Program
{
public static async Task<int> Main(string[] args)
{
try
{
var exitCode = await NugetUtilProgram.RunAsync(args);
if (!IsUsageInvocation(args))
{
PrintExitMessage(exitCode);
}
return exitCode;
}
catch (Exception ex)
{
Console.Error.WriteLine(ex.Message);
return ExitCodes.InvalidArgsOrConfig;
}
}
private static bool IsUsageInvocation(string[] args)
{
return args.Any(a => string.Equals(a, "-h", StringComparison.OrdinalIgnoreCase) ||
string.Equals(a, "--help", StringComparison.OrdinalIgnoreCase) ||
string.Equals(a, "-v", StringComparison.OrdinalIgnoreCase) ||
string.Equals(a, "--version", StringComparison.OrdinalIgnoreCase) ||
string.Equals(a, "/?", StringComparison.OrdinalIgnoreCase));
}
private static void PrintExitMessage(int exitCode)
{
if (exitCode == ExitCodes.Success)
{
Console.WriteLine("Job finished successfully.");
return;
}
Console.Error.WriteLine($"Job failed with exit code: {exitCode}");
}
}