aswi2021tri-musketyri-gitlab/Server/ServerApp/User/CommandsAcceptor.cs @ 4b847de5
1 |
using System; |
---|---|
2 |
using System.Collections.Generic; |
3 |
using System.Linq; |
4 |
using System.Text; |
5 |
using System.Threading.Tasks; |
6 |
|
7 |
namespace ServerApp.User |
8 |
{
|
9 |
|
10 |
|
11 |
public class CommandsAcceptor |
12 |
{
|
13 |
|
14 |
public static void AcceptCommand() |
15 |
{
|
16 |
while (true) { |
17 |
string command = Console.ReadLine(); |
18 |
Command c = ParseString(command); |
19 |
CheckCommand(c); |
20 |
Program.NotifyUserMessage(command); |
21 |
}
|
22 |
}
|
23 |
|
24 |
private static Command ParseString(string str) |
25 |
{
|
26 |
string[] splits = str.Split(' '); |
27 |
Command command = new Command(); |
28 |
|
29 |
command.MainCommand = splits[0]; |
30 |
|
31 |
for(int i = 1; i < splits.Length; i++) |
32 |
{
|
33 |
|
34 |
string current = splits[i]; |
35 |
if (current.StartsWith("-")) |
36 |
{
|
37 |
command.AddFlag(current.Substring(1)); |
38 |
}
|
39 |
else
|
40 |
{
|
41 |
command.AddData(current); |
42 |
}
|
43 |
}
|
44 |
|
45 |
return command; |
46 |
}
|
47 |
|
48 |
private static void CheckCommand(Command c) |
49 |
{
|
50 |
Console.WriteLine(c); |
51 |
|
52 |
switch (c.MainCommand) |
53 |
{
|
54 |
case "data": break; |
55 |
case "model": break; |
56 |
case "help": break; |
57 |
}
|
58 |
}
|
59 |
|
60 |
private void PrintUsage() |
61 |
{
|
62 |
|
63 |
}
|
64 |
}
|
65 |
}
|
- « Předchozí
- 1
- 2
- Další »