Mercurial > defical
comparison defical-sharp/defical-cli/argumentparser.cs @ 0:ebed2bd0d300
Initial import from svn. History be damned.
author | Edho P. Arief <me@myconan.net> |
---|---|
date | Fri, 02 Apr 2010 23:11:57 +0700 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:ebed2bd0d300 |
---|---|
1 namespace defical_cli | |
2 { | |
3 public partial class Program | |
4 { | |
5 private partial class main | |
6 { | |
7 private bool getArguments(string[] args) | |
8 { | |
9 bool ret = true; | |
10 int numArgs = args.Length; | |
11 for (int i = 0; i < numArgs; i++) | |
12 { | |
13 switch (args[i].Substring(0, 1)) | |
14 { | |
15 case "-": | |
16 { | |
17 switch (args[i].Substring(1, 1)) | |
18 { | |
19 case "g": | |
20 { | |
21 args[i] = "--graph"; | |
22 i--; | |
23 break; | |
24 } | |
25 case "n": | |
26 { | |
27 args[i] = "--numver"; | |
28 i--; | |
29 break; | |
30 } | |
31 case "d": | |
32 { | |
33 args[i] = "--numdef"; | |
34 i--; | |
35 break; | |
36 } | |
37 case "a": | |
38 { | |
39 args[i] = "--algorithm"; | |
40 i--; | |
41 break; | |
42 } | |
43 case "-": | |
44 { | |
45 if (i < numArgs - 1) | |
46 { | |
47 switch (args[i].Substring(2)) | |
48 { | |
49 case "graph": | |
50 #region graphparser | |
51 { | |
52 switch (args[i + 1]) | |
53 { | |
54 case "wheel": | |
55 case "fan": | |
56 case "doublefan": | |
57 { | |
58 this.graphType = args[i + 1]; | |
59 break; | |
60 } | |
61 default: | |
62 { | |
63 ret = false; | |
64 break; | |
65 } | |
66 } | |
67 break; | |
68 } | |
69 #endregion | |
70 case "numver": | |
71 #region numverparser | |
72 { | |
73 int tempNumVer = -1; | |
74 if (parseNum(args[i + 1], 5, 10, out tempNumVer)) | |
75 { | |
76 this.numVer = tempNumVer; | |
77 } | |
78 else { ret = false; } | |
79 break; | |
80 } | |
81 #endregion | |
82 case "numdef": | |
83 #region numdefparser | |
84 { | |
85 int tempNumDef = -1; | |
86 if (parseNum(args[i + 1], 0, 10, out tempNumDef)) | |
87 { | |
88 this.numDef = tempNumDef; | |
89 } | |
90 else { ret = false; } | |
91 break; | |
92 } | |
93 #endregion | |
94 case "algorithm": | |
95 #region algorithmparser | |
96 { | |
97 switch (args[i + 1]) | |
98 { | |
99 case "backtrack": | |
100 this.algorithm = args[i + 1]; | |
101 break; | |
102 default: | |
103 ret = false; | |
104 break; | |
105 } | |
106 break; | |
107 } | |
108 #endregion | |
109 } | |
110 i++; | |
111 } | |
112 else { ret = false; } | |
113 break; | |
114 } | |
115 } | |
116 break; | |
117 } | |
118 default: | |
119 { | |
120 ret = false; | |
121 break; | |
122 } | |
123 } | |
124 } | |
125 //TODO | |
126 return ret; | |
127 } | |
128 | |
129 } | |
130 } | |
131 } |