-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathTerminal.cs
68 lines (55 loc) · 2.35 KB
/
Terminal.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
using ArcNET.Utilities;
using Spectre.Console;
using Spectre.Console.Rendering;
using System;
using System.Collections.Generic;
using System.Reflection;
namespace ArcNET.Terminal;
public static class Terminal
{
public static void RenderLogo()
{
AnsiConsole.Write(new FigletText("ArcNET v0.0.1").Color(Color.Green));
}
public static IRenderable DirectoryTable(string dirPath, IEnumerable<Tuple<List<string>, Parser.FileType>> data)
{
Table table = new Table()
.RoundedBorder()
.AddColumn("Summary for dirPath:")
.AddColumn($"{dirPath}");
foreach ((List<string> pathToFiles, Parser.FileType fileType) in data)
table.AddRow($"{Enum.GetName(typeof(Parser.FileType), fileType)}", $"{pathToFiles.Count}");
return table;
}
public static IRenderable ConfigTable()
{
Table table = new Table()
.RoundedBorder()
.AddColumn("Parameter name")
.AddColumn("Parameter value");
const BindingFlags bindingFlags = BindingFlags.Public | BindingFlags.NonPublic |
BindingFlags.Instance | BindingFlags.Static;
foreach (FieldInfo field in typeof(HighResConfig).GetFields(bindingFlags))
table.AddRow($"{field.Name}", $"{field.GetValue(field)}");
return table;
}
//TODO: merge with summary table?
public static IRenderable ReportTable(string dirPath, IEnumerable<Tuple<List<string>, Parser.FileType>> data)
{
Table table = new Table()
.RoundedBorder()
.AddColumn("Parsing report for dirPath:")
.AddColumn($"{dirPath}");
foreach ((List<string> pathToFiles, Parser.FileType fileType) in data)
table.AddRow($"{Enum.GetName(typeof(Parser.FileType), fileType)} files parsed:", $"{pathToFiles.Count}");
return table;
}
public static string GetMainMenuChoice()
=> AnsiConsole.Prompt(
new SelectionPrompt<string>()
.Title("[green]What would you like to do[/]?")
.PageSize(5)
.MoreChoicesText("[grey](Move up and down to reveal more choices)[/]")
.AddChoices("Extract game data", "Parse extracted game data", "Install High-Res patch",
"Uninstall High-Res patch", "Launch Arcanum.exe"));
}