-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathProgram.cs
More file actions
116 lines (96 loc) · 3.16 KB
/
Program.cs
File metadata and controls
116 lines (96 loc) · 3.16 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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
// See https://aka.ms/new-console-template for more information
using Aliyun.OSS.Util;
using Newtonsoft.Json.Linq;
using RS.Snail.JJJ.boot;
using RS.Snail.JJJ.robot.include;
using RS.Snail.JJJ.test;
using RS.Snail.JJJ.utils;
using RS.Tools.Common.Utils;
using System.Reflection;
using System.Text.RegularExpressions;
using System.Xml;
namespace RS.Snail.JJJ;
public class Entry
{
// Main函数异步启动并且接收命令数组
private static Context _context;
static async Task Main(string[] args)
{
bool isRestart = false;
bool isTest = false;
bool isDebug = false;
if (args.Length > 0)
{
foreach (var item in args)
{
if (item == "restart") isRestart = true;
if (item == "test") isTest = true;
if (item == "debug") isDebug = true;
}
}
_context = new Context(isRestart, isTest, isDebug);
await Input();
}
// 等待并接收指令
async private static Task Input()
{
await Task.Run(() =>
{
do
{
// Your code could perform some useful task in the following loop. However,
// for the sake of this example we'll merely pause for a quarter second.
while (Console.KeyAvailable == false) Task.Delay(250).Wait(); // Loop until input is entered.
var str = Console.ReadLine();
if (string.IsNullOrEmpty(str)) continue;
AcceptCommand(str);
} while (true);
});
}
private static void AcceptCommand(string command)
{
switch (command.ToLower())
{
case "exit":
case "stop":
_context.Exit();
break;
case "reboot":
case "restart":
_context.Restart();
break;
case "save":
_context.BackupM.SaveNow();
break;
case "login":
break;
case "weekday":
var wd = Snail.JJJ.Client.core.game.module.TimeM.GetWeekDayStatic();
Console.WriteLine($"星期{wd}");
break;
default:
Console.WriteLine("你说啥?");
return;
}
}
//public static void Main()
//{
// Console.WriteLine("hello world");
// // q: 如何按指定位数取反?
// do
// {
// var input = Console.ReadLine();
// if (StringHelper.IsNumeric(input))
// {
// var data = DivinationHelper.GetDivination(Convert.ToInt32(input));
// Console.WriteLine($"字数 {data.Length}");
// Console.WriteLine(data);
// Console.WriteLine();
// }
// } while (true);
// //var data = System.IO.File.ReadAllText("J:\\Projects\\RS\\Snail\\JJJ\\RS.JJJ\\bin\\Debug\\net6.0\\OUT\\zhouyi64.json");
// //var jo = JObject.Parse(data);
// //IOHelper.SaveCSV(Tools.Common.Enums.CSVType.RobotData, jo, "zhouyi64");
// // 检查启动参数是否有restart
//}
}