-
Notifications
You must be signed in to change notification settings - Fork 935
/
Copy pathProgram.cs
63 lines (55 loc) · 1.33 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
using System;
using System.IO;
using System.Linq;
using System.Text;
namespace BuildTool
{
public static class Program
{
public static int Main(string[] args)
{
var command = args[0];
switch (command)
{
case "pick-folder":
var folders = Directory.GetDirectories(args[1]);
for (var i = 0; i < folders.Length; i++)
{
Console.WriteLine((char) ('A' + i) + ": " + Path.GetFileName(folders[i]));
}
var sb = new StringBuilder();
for (var i = 3; i < args.Length; i++)
sb.Append(args[i]);
var remainingArgs = sb.ToString();
while (true)
{
Console.WriteLine(remainingArgs);
var key = Console.ReadKey();
Console.WriteLine();
if (char.IsLetter(key.KeyChar))
{
var index = key.KeyChar.ToString().ToUpper()[0] - 'A';
File.WriteAllText(args[2], folders[index]);
break;
}
}
return 0;
case "prompt":
var characters = args[1].ToUpper().ToList();
while (true)
{
Console.WriteLine($"[{string.Join(", ", characters)}]?");
var key = char.ToUpper(Console.ReadKey().KeyChar);
Console.WriteLine();
if (characters.Contains(key))
{
return characters.IndexOf(key);
}
}
default:
Console.WriteLine($"Invalid command: {command}");
return 255;
}
}
}
}