Repository navigation
Expand file tree
/
Copy pathParser.cs
More file actions
70 lines (59 loc) 路 2.4 KB
/
Copy pathParser.cs
File metadata and controls
70 lines (59 loc) 路 2.4 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
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
using System;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
namespace NameChk.CLI
{
static class Parser
{
static IProvider Provider;
internal static void Parse(string[] args)
{
if (args.Length == 0)
{
ShowHelp();
return;
}
ShowVersion();
RunProvider(args);
}
static void RunProvider(string[] names)
{
Provider = new NuGetProvider();
Console.WriteLine();
var Checks = Provider.CheckAvailability(names)
.Select(async c =>
{
var (name, isAvailable) = await c;
var color = isAvailable ? ConsoleColor.Green : ConsoleColor.Red;
Console.ForegroundColor = color;
Console.WriteLine($" {name} {(isAvailable ? Constants.PACKAGE_AVAILABLE : Constants.PACKAGE_UNVAILABLE)}");
}).ToArray();
Task.WaitAll(Checks);
Console.ResetColor();
Console.WriteLine();
}
static void ShowVersion()
{
var versionString = Assembly.GetEntryAssembly()
.GetCustomAttribute<AssemblyInformationalVersionAttribute>()
.InformationalVersion
.ToString();
Console.WriteLine($"{Constants.APP_NAME} v{versionString}");
Console.WriteLine("----------------");
}
static void ShowHelp()
{
ShowVersion();
Console.WriteLine($"\nUsage: {Constants.APP_NAME} [names...]");
Console.WriteLine("\nnames:");
Console.WriteLine(" list of names to check for the availability");
Console.WriteLine("\nEx:");
Console.WriteLine($" {Constants.APP_NAME} miniature-fiesta reimagined-engine scaling-adventure");
Console.WriteLine("\n miniature-fiesta is available");
Console.WriteLine(" reimagined-engine is unavailable");
Console.WriteLine(" scaling-adventure is unavailable");
Console.WriteLine();
}
}
}