-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBackupController.cs
More file actions
49 lines (38 loc) · 1.15 KB
/
Copy pathBackupController.cs
File metadata and controls
49 lines (38 loc) · 1.15 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
using System.Text.RegularExpressions;
using Backup.Components;
using Backup.Commands.Core;
namespace Backup;
public static class BackupController
{
public static void Main(string[] args)
{
if (args.Length == 0)
ContinuousMode();
else
CommandExecutor.Execute(args);
}
private static void ContinuousMode()
{
Logger.Log("started continuous mode\nrun 'help' for options, and 'exit' to exit");
const string tokenPattern = @"[^\s""']+|""([^""]*)""|'([^']*)'";
while (true)
{
string? input = Logger.Prompt(">");
if (input is null)
continue;
if (input == "exit")
return;
string[] args = Regex.Matches(input, tokenPattern)
.Select(m =>
{
if (m.Groups[1].Success)
return m.Groups[1].Value;
if (m.Groups[2].Success)
return m.Groups[2].Value;
return m.Value;
})
.ToArray();
CommandExecutor.Execute(args);
}
}
}