-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainLibrary.cs
More file actions
64 lines (63 loc) · 2.76 KB
/
Copy pathMainLibrary.cs
File metadata and controls
64 lines (63 loc) · 2.76 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
using ShellLibrary.Cmd.Command;
using ShellLibrary.Cmd.Parser;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using System.Threading.Tasks;
namespace ShellLibrary.Cmd
{
public class MainLibrary
{
public class ShellSetting
{
public string? ShellName { get; set; }
public string? ShellVerion { get; set; }
public string? ShellDescription { get; set; }
public bool? ShellTypwriterstyle { get; set; }
public char ShellDelimiter { get; set; } = '|';
public bool ShellWelcomeTemplate { get; set; } = true;
public bool ShellCursorVisible { get; set; } = true;
public bool ShellTitle { get; set; }= true;
public bool ShellRunBinary { get; set; } = true;
}
public class BuildShell
{
public static ShellSetting ShellSetting = new ShellSetting();
public static TypeWriter TypeWriter = new TypeWriter();
public static Command.MainLoop MainLoop = new Command.MainLoop();
public static CommandRepository CommandRepository = new CommandRepository();
public static CommandAndArgsParser CommandAndArgsParser = new CommandAndArgsParser();
public static Register Register = new Register();
public static MessageReops MessageReops = new MessageReops();
public static Process ProcessDocker = new Process();
public static StringBuilder Pipeline = new StringBuilder();
public static List<string> CommandHistory = new List<string>();
public static ProcessStartInfo DockerStartInfo = new ProcessStartInfo();
public async Task WelcomeScreenAsync()
{
string WriteHistory = MainLoop.HistoryCommandWriteEnabled? "Enabled" : "Disabled";
string WelcomeScreen = $@"{ShellSetting.ShellName} {ShellSetting.ShellVerion}
====================
{ShellSetting.ShellDescription}
HistoryWrite:{WriteHistory}
Try 'help' to see available commands.
Welcome back ,{Environment.UserName}";
await TypeWriter.Write(WelcomeScreen,addnewline:true,clearscreen:true);
}
public async Task BuildAsync()
{
if (ShellSetting.ShellWelcomeTemplate)
{
await WelcomeScreenAsync();
}
if (ShellSetting.ShellTitle&&!string.IsNullOrEmpty(ShellSetting.ShellName))
{
Console.Title = ShellSetting.ShellName;
}
Console.CursorVisible = ShellSetting.ShellCursorVisible;
MainLoop.Loop();
}
}
}
}