-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDwarfCMD.cs
More file actions
49 lines (40 loc) · 895 Bytes
/
DwarfCMD.cs
File metadata and controls
49 lines (40 loc) · 895 Bytes
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;
using System.Collections.Generic;
namespace DwarfCMD
{
public delegate void dwarfCmd(string args);
public abstract class DwarfCMD
{
protected Dictionary<string, dwarfCmd> dwarfCmds;
/** Parses a user command to a delegate function.
*
* @param cmd Command to be parsed
*/
public void parseCmd(string cmd)
{
//TODO: Parse cmd, seperate command from command args
if (String.IsNullOrWhiteSpace(cmd))
{
return;
}
string[] cmdAndArgs = cmd.Split(new Char[] {' '}, 2);
string args = null;
cmd = cmdAndArgs[0];
try
{
args = cmdAndArgs[1];
} catch (IndexOutOfRangeException oorE) {
;
}
try
{
dwarfCmds[cmd](args);
} catch (KeyNotFoundException kE) {
Console.WriteLine("Unrecognized Command: "+cmd);
} catch (ArgumentNullException anE){
;
}
return;
}
}
}