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