author | HG Automerge |
Mon, 26 Dec 2016 10:13:07 +0000 | |
branch | jv |
changeset 21247 | 9ee1206fc247 |
parent 20077 | e0e720fce465 |
child 23107 | 40173e082cbc |
permissions | -rw-r--r-- |
19988
148721e96482
Added convenience methods to build CmdLineOptions.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
18120
diff
changeset
|
1 |
" |
148721e96482
Added convenience methods to build CmdLineOptions.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
18120
diff
changeset
|
2 |
COPYRIGHT (c) 2006 by eXept Software AG |
148721e96482
Added convenience methods to build CmdLineOptions.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
18120
diff
changeset
|
3 |
All Rights Reserved |
148721e96482
Added convenience methods to build CmdLineOptions.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
18120
diff
changeset
|
4 |
|
148721e96482
Added convenience methods to build CmdLineOptions.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
18120
diff
changeset
|
5 |
This software is furnished under a license and may be used |
148721e96482
Added convenience methods to build CmdLineOptions.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
18120
diff
changeset
|
6 |
only in accordance with the terms of that license and with the |
148721e96482
Added convenience methods to build CmdLineOptions.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
18120
diff
changeset
|
7 |
inclusion of the above copyright notice. This software may not |
148721e96482
Added convenience methods to build CmdLineOptions.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
18120
diff
changeset
|
8 |
be provided or otherwise made available to, or used by, any |
148721e96482
Added convenience methods to build CmdLineOptions.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
18120
diff
changeset
|
9 |
other person. No title to or ownership of the software is |
148721e96482
Added convenience methods to build CmdLineOptions.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
18120
diff
changeset
|
10 |
hereby transferred. |
148721e96482
Added convenience methods to build CmdLineOptions.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
18120
diff
changeset
|
11 |
" |
13402 | 12 |
"{ Package: 'stx:libbasic' }" |
13 |
||
17340 | 14 |
"{ NameSpace: Smalltalk }" |
15 |
||
13939 | 16 |
TestCase subclass:#CmdLineParserTest |
13402 | 17 |
instanceVariableNames:'optionA optionB optionBValue' |
18 |
classVariableNames:'' |
|
19 |
poolDictionaries:'' |
|
20 |
category:'System-Support-Command line' |
|
21 |
! |
|
22 |
||
19988
148721e96482
Added convenience methods to build CmdLineOptions.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
18120
diff
changeset
|
23 |
!CmdLineParserTest class methodsFor:'documentation'! |
148721e96482
Added convenience methods to build CmdLineOptions.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
18120
diff
changeset
|
24 |
|
148721e96482
Added convenience methods to build CmdLineOptions.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
18120
diff
changeset
|
25 |
copyright |
148721e96482
Added convenience methods to build CmdLineOptions.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
18120
diff
changeset
|
26 |
" |
148721e96482
Added convenience methods to build CmdLineOptions.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
18120
diff
changeset
|
27 |
COPYRIGHT (c) 2006 by eXept Software AG |
148721e96482
Added convenience methods to build CmdLineOptions.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
18120
diff
changeset
|
28 |
All Rights Reserved |
148721e96482
Added convenience methods to build CmdLineOptions.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
18120
diff
changeset
|
29 |
|
148721e96482
Added convenience methods to build CmdLineOptions.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
18120
diff
changeset
|
30 |
This software is furnished under a license and may be used |
148721e96482
Added convenience methods to build CmdLineOptions.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
18120
diff
changeset
|
31 |
only in accordance with the terms of that license and with the |
148721e96482
Added convenience methods to build CmdLineOptions.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
18120
diff
changeset
|
32 |
inclusion of the above copyright notice. This software may not |
148721e96482
Added convenience methods to build CmdLineOptions.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
18120
diff
changeset
|
33 |
be provided or otherwise made available to, or used by, any |
148721e96482
Added convenience methods to build CmdLineOptions.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
18120
diff
changeset
|
34 |
other person. No title to or ownership of the software is |
148721e96482
Added convenience methods to build CmdLineOptions.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
18120
diff
changeset
|
35 |
hereby transferred. |
148721e96482
Added convenience methods to build CmdLineOptions.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
18120
diff
changeset
|
36 |
" |
148721e96482
Added convenience methods to build CmdLineOptions.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
18120
diff
changeset
|
37 |
! ! |
13402 | 38 |
|
17340 | 39 |
!CmdLineParserTest class methodsFor:'queries'! |
40 |
||
41 |
coveredClassNames |
|
42 |
^ #( |
|
43 |
'CmdLineOption' |
|
44 |
'CmdLineOptionError' |
|
45 |
'CmdLineParser' |
|
46 |
) |
|
47 |
! ! |
|
48 |
||
13402 | 49 |
!CmdLineParserTest methodsFor:'accessing'! |
50 |
||
51 |
cmdlineOptionA |
|
52 |
||
53 |
^CmdLineOption new |
|
54 |
short: $a; |
|
55 |
long: 'option-a'; |
|
56 |
description: 'option a with no arg'; |
|
57 |
action:[optionA := true] |
|
58 |
||
59 |
"Created: / 28-01-2009 / 11:56:28 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
60 |
"Modified: / 08-06-2009 / 14:34:00 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
61 |
! |
|
62 |
||
63 |
cmdlineOptionB |
|
64 |
||
65 |
^CmdLineOption new |
|
66 |
short: $b; |
|
67 |
long: 'option-b'; |
|
68 |
description: 'option b with one arg'; |
|
69 |
action:[:value | optionB := true. optionBValue := value] |
|
70 |
||
71 |
"Created: / 28-01-2009 / 12:01:43 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
72 |
"Modified: / 08-06-2009 / 14:33:50 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
73 |
! ! |
|
74 |
||
75 |
!CmdLineParserTest methodsFor:'initialization'! |
|
76 |
||
77 |
setUp |
|
78 |
||
79 |
optionA := optionB := false. |
|
80 |
optionBValue := nil |
|
81 |
||
82 |
"Created: / 28-01-2009 / 12:01:01 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
83 |
! ! |
|
84 |
||
85 |
!CmdLineParserTest methodsFor:'tests'! |
|
86 |
||
87 |
test_01 |
|
88 |
||
89 |
CmdLineParser |
|
90 |
parse: #('-a') |
|
91 |
for: self. |
|
92 |
||
93 |
self assert: optionA. |
|
94 |
self deny: optionB. |
|
95 |
||
96 |
"Created: / 28-01-2009 / 14:19:18 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
97 |
"Modified: / 29-05-2009 / 15:47:19 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
98 |
! |
|
99 |
||
100 |
test_02 |
|
101 |
||
102 |
CmdLineParser |
|
103 |
parse: #('--option-a') |
|
104 |
for: self. |
|
105 |
||
106 |
self assert: optionA. |
|
107 |
self deny: optionB. |
|
108 |
||
109 |
"Created: / 28-01-2009 / 14:19:38 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
110 |
"Modified: / 29-05-2009 / 15:47:30 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
111 |
! |
|
112 |
||
113 |
test_04a |
|
114 |
||
115 |
CmdLineParser |
|
116 |
parse: #('--option-b= value') |
|
117 |
for: self. |
|
118 |
||
119 |
self deny: optionA. |
|
120 |
self assert: optionB. |
|
121 |
self assert: optionBValue = ' value' |
|
122 |
||
123 |
"Created: / 30-01-2009 / 10:43:40 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
124 |
"Modified: / 29-05-2009 / 15:47:34 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
125 |
! |
|
126 |
||
127 |
test_04b |
|
128 |
||
129 |
self |
|
130 |
should:[CmdLineParser parse: #('--option-b') for: self] |
|
131 |
raise: CmdLineOptionError |
|
132 |
||
133 |
"Created: / 30-01-2009 / 10:43:37 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
134 |
"Modified: / 29-05-2009 / 15:47:39 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
135 |
! |
|
136 |
||
137 |
test_04c |
|
138 |
||
139 |
CmdLineParser parse: #('--option-b=') for: self. |
|
140 |
||
141 |
self deny: optionA. |
|
142 |
self assert: optionB. |
|
143 |
self assert: optionBValue = '' |
|
144 |
||
145 |
"Created: / 30-01-2009 / 10:44:20 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
146 |
"Modified: / 29-05-2009 / 15:47:44 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
147 |
! |
|
148 |
||
149 |
test_05 |
|
150 |
||
151 |
CmdLineParser |
|
152 |
parse: #('-b' 'value') |
|
153 |
for: self. |
|
154 |
||
155 |
self deny: optionA. |
|
156 |
self assert: optionB. |
|
157 |
self assert: optionBValue = 'value'. |
|
158 |
||
159 |
"Created: / 03-02-2009 / 17:38:51 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
160 |
"Modified: / 29-05-2009 / 15:47:50 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
161 |
! |
|
162 |
||
163 |
test_06 |
|
164 |
||
165 |
CmdLineParser |
|
166 |
parse: #('-a' '-b' 'value') |
|
167 |
for: self. |
|
168 |
||
169 |
self assert: optionA. |
|
170 |
self assert: optionB. |
|
171 |
self assert: optionBValue = 'value'. |
|
172 |
||
173 |
"Created: / 03-02-2009 / 17:39:54 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
174 |
"Modified: / 29-05-2009 / 15:47:56 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
175 |
! |
|
176 |
||
177 |
test_07 |
|
178 |
||
179 |
CmdLineParser |
|
180 |
parse: #('-ab' 'value') |
|
181 |
for: self. |
|
182 |
||
183 |
self assert: optionA. |
|
184 |
self assert: optionB. |
|
185 |
self assert: optionBValue = 'value'. |
|
186 |
||
187 |
"Created: / 03-02-2009 / 17:40:04 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
188 |
"Modified: / 29-05-2009 / 15:48:02 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
189 |
! |
|
190 |
||
191 |
test_08 |
|
192 |
||
193 |
| rest | |
|
194 |
rest := CmdLineParser |
|
195 |
parse: #('-a' '/tmp/abc.txt') |
|
196 |
for: self. |
|
197 |
||
198 |
self assert: optionA. |
|
199 |
self assert: optionB not. |
|
200 |
self assert: rest asArray = #('/tmp/abc.txt') |
|
201 |
||
202 |
"Created: / 08-06-2009 / 14:51:54 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
203 |
! |
|
204 |
||
205 |
test_09 |
|
206 |
||
207 |
| rest | |
|
208 |
rest := CmdLineParser |
|
209 |
parse: #('/tmp/abc.txt') |
|
210 |
for: self. |
|
211 |
||
212 |
self assert: optionA not. |
|
213 |
self assert: optionB not. |
|
214 |
self assert: rest asArray = #('/tmp/abc.txt') |
|
215 |
||
216 |
"Created: / 08-06-2009 / 14:52:13 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
19988
148721e96482
Added convenience methods to build CmdLineOptions.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
18120
diff
changeset
|
217 |
! |
148721e96482
Added convenience methods to build CmdLineOptions.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
18120
diff
changeset
|
218 |
|
148721e96482
Added convenience methods to build CmdLineOptions.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
18120
diff
changeset
|
219 |
test_10 |
148721e96482
Added convenience methods to build CmdLineOptions.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
18120
diff
changeset
|
220 |
| option | |
148721e96482
Added convenience methods to build CmdLineOptions.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
18120
diff
changeset
|
221 |
|
148721e96482
Added convenience methods to build CmdLineOptions.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
18120
diff
changeset
|
222 |
option := CmdLineOption new spec:$a. |
148721e96482
Added convenience methods to build CmdLineOptions.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
18120
diff
changeset
|
223 |
self assert: option short == $a. |
148721e96482
Added convenience methods to build CmdLineOptions.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
18120
diff
changeset
|
224 |
self assert: option long isNil. |
148721e96482
Added convenience methods to build CmdLineOptions.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
18120
diff
changeset
|
225 |
|
148721e96482
Added convenience methods to build CmdLineOptions.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
18120
diff
changeset
|
226 |
option := CmdLineOption new spec:'-a'. |
148721e96482
Added convenience methods to build CmdLineOptions.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
18120
diff
changeset
|
227 |
self assert: option short == $a. |
148721e96482
Added convenience methods to build CmdLineOptions.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
18120
diff
changeset
|
228 |
self assert: option long isNil. |
148721e96482
Added convenience methods to build CmdLineOptions.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
18120
diff
changeset
|
229 |
|
148721e96482
Added convenience methods to build CmdLineOptions.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
18120
diff
changeset
|
230 |
option := CmdLineOption new spec:'add'. |
148721e96482
Added convenience methods to build CmdLineOptions.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
18120
diff
changeset
|
231 |
self assert: option short isNil. |
148721e96482
Added convenience methods to build CmdLineOptions.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
18120
diff
changeset
|
232 |
self assert: option long = 'add'. |
148721e96482
Added convenience methods to build CmdLineOptions.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
18120
diff
changeset
|
233 |
|
148721e96482
Added convenience methods to build CmdLineOptions.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
18120
diff
changeset
|
234 |
option := CmdLineOption new spec:'--add'. |
148721e96482
Added convenience methods to build CmdLineOptions.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
18120
diff
changeset
|
235 |
self assert: option short isNil. |
148721e96482
Added convenience methods to build CmdLineOptions.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
18120
diff
changeset
|
236 |
self assert: option long = 'add'. |
148721e96482
Added convenience methods to build CmdLineOptions.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
18120
diff
changeset
|
237 |
|
148721e96482
Added convenience methods to build CmdLineOptions.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
18120
diff
changeset
|
238 |
option := CmdLineOption new spec:#('-a' '--add'). |
148721e96482
Added convenience methods to build CmdLineOptions.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
18120
diff
changeset
|
239 |
self assert: option short == $a. |
148721e96482
Added convenience methods to build CmdLineOptions.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
18120
diff
changeset
|
240 |
self assert: option long = 'add'. |
148721e96482
Added convenience methods to build CmdLineOptions.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
18120
diff
changeset
|
241 |
|
148721e96482
Added convenience methods to build CmdLineOptions.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
18120
diff
changeset
|
242 |
"Created: / 14-06-2016 / 06:58:15 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
20076
ff2f4d06a2fa
CmdLineParser refactored and added an option to ignore unknown options
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
19988
diff
changeset
|
243 |
! |
ff2f4d06a2fa
CmdLineParser refactored and added an option to ignore unknown options
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
19988
diff
changeset
|
244 |
|
ff2f4d06a2fa
CmdLineParser refactored and added an option to ignore unknown options
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
19988
diff
changeset
|
245 |
test_11 |
ff2f4d06a2fa
CmdLineParser refactored and added an option to ignore unknown options
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
19988
diff
changeset
|
246 |
|
ff2f4d06a2fa
CmdLineParser refactored and added an option to ignore unknown options
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
19988
diff
changeset
|
247 |
| rest | |
ff2f4d06a2fa
CmdLineParser refactored and added an option to ignore unknown options
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
19988
diff
changeset
|
248 |
rest := CmdLineParser new |
ff2f4d06a2fa
CmdLineParser refactored and added an option to ignore unknown options
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
19988
diff
changeset
|
249 |
ignoreUnknownOptions: true; |
ff2f4d06a2fa
CmdLineParser refactored and added an option to ignore unknown options
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
19988
diff
changeset
|
250 |
parse: #('--ignored-option' '/tmp/abc.txt') |
ff2f4d06a2fa
CmdLineParser refactored and added an option to ignore unknown options
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
19988
diff
changeset
|
251 |
for: self. |
ff2f4d06a2fa
CmdLineParser refactored and added an option to ignore unknown options
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
19988
diff
changeset
|
252 |
|
ff2f4d06a2fa
CmdLineParser refactored and added an option to ignore unknown options
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
19988
diff
changeset
|
253 |
self assert: optionA not. |
ff2f4d06a2fa
CmdLineParser refactored and added an option to ignore unknown options
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
19988
diff
changeset
|
254 |
self assert: optionB not. |
ff2f4d06a2fa
CmdLineParser refactored and added an option to ignore unknown options
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
19988
diff
changeset
|
255 |
self assert: rest asArray = #('--ignored-option' '/tmp/abc.txt') |
ff2f4d06a2fa
CmdLineParser refactored and added an option to ignore unknown options
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
19988
diff
changeset
|
256 |
|
ff2f4d06a2fa
CmdLineParser refactored and added an option to ignore unknown options
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
19988
diff
changeset
|
257 |
"Created: / 29-06-2016 / 00:15:28 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
20077
e0e720fce465
CmdLineParser refactored to allow both `--long-option=value` and `--long-option value` forms
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
20076
diff
changeset
|
258 |
! |
e0e720fce465
CmdLineParser refactored to allow both `--long-option=value` and `--long-option value` forms
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
20076
diff
changeset
|
259 |
|
e0e720fce465
CmdLineParser refactored to allow both `--long-option=value` and `--long-option value` forms
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
20076
diff
changeset
|
260 |
test_12a |
e0e720fce465
CmdLineParser refactored to allow both `--long-option=value` and `--long-option value` forms
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
20076
diff
changeset
|
261 |
|
e0e720fce465
CmdLineParser refactored to allow both `--long-option=value` and `--long-option value` forms
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
20076
diff
changeset
|
262 |
| parser longOptionValue | |
e0e720fce465
CmdLineParser refactored to allow both `--long-option=value` and `--long-option value` forms
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
20076
diff
changeset
|
263 |
parser := CmdLineParser new |
e0e720fce465
CmdLineParser refactored to allow both `--long-option=value` and `--long-option value` forms
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
20076
diff
changeset
|
264 |
on: #('-l' '--long-option=VALUE') do:[:value | longOptionValue := value ]; |
e0e720fce465
CmdLineParser refactored to allow both `--long-option=value` and `--long-option value` forms
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
20076
diff
changeset
|
265 |
yourself. |
e0e720fce465
CmdLineParser refactored to allow both `--long-option=value` and `--long-option value` forms
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
20076
diff
changeset
|
266 |
|
e0e720fce465
CmdLineParser refactored to allow both `--long-option=value` and `--long-option value` forms
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
20076
diff
changeset
|
267 |
parser parse:#('-l' 'v1'). |
e0e720fce465
CmdLineParser refactored to allow both `--long-option=value` and `--long-option value` forms
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
20076
diff
changeset
|
268 |
self assert: longOptionValue = 'v1'. |
e0e720fce465
CmdLineParser refactored to allow both `--long-option=value` and `--long-option value` forms
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
20076
diff
changeset
|
269 |
|
e0e720fce465
CmdLineParser refactored to allow both `--long-option=value` and `--long-option value` forms
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
20076
diff
changeset
|
270 |
parser parse:#('--long-option=v2'). |
e0e720fce465
CmdLineParser refactored to allow both `--long-option=value` and `--long-option value` forms
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
20076
diff
changeset
|
271 |
self assert: longOptionValue = 'v2'. |
e0e720fce465
CmdLineParser refactored to allow both `--long-option=value` and `--long-option value` forms
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
20076
diff
changeset
|
272 |
|
e0e720fce465
CmdLineParser refactored to allow both `--long-option=value` and `--long-option value` forms
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
20076
diff
changeset
|
273 |
"Created: / 29-06-2016 / 17:07:58 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
e0e720fce465
CmdLineParser refactored to allow both `--long-option=value` and `--long-option value` forms
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
20076
diff
changeset
|
274 |
! |
e0e720fce465
CmdLineParser refactored to allow both `--long-option=value` and `--long-option value` forms
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
20076
diff
changeset
|
275 |
|
e0e720fce465
CmdLineParser refactored to allow both `--long-option=value` and `--long-option value` forms
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
20076
diff
changeset
|
276 |
test_12b |
e0e720fce465
CmdLineParser refactored to allow both `--long-option=value` and `--long-option value` forms
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
20076
diff
changeset
|
277 |
|
e0e720fce465
CmdLineParser refactored to allow both `--long-option=value` and `--long-option value` forms
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
20076
diff
changeset
|
278 |
| parser longOptionValue | |
e0e720fce465
CmdLineParser refactored to allow both `--long-option=value` and `--long-option value` forms
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
20076
diff
changeset
|
279 |
parser := CmdLineParser new |
e0e720fce465
CmdLineParser refactored to allow both `--long-option=value` and `--long-option value` forms
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
20076
diff
changeset
|
280 |
on: #('-l' '--long-option VALUE') do:[:value | longOptionValue := value ]; |
e0e720fce465
CmdLineParser refactored to allow both `--long-option=value` and `--long-option value` forms
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
20076
diff
changeset
|
281 |
yourself. |
e0e720fce465
CmdLineParser refactored to allow both `--long-option=value` and `--long-option value` forms
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
20076
diff
changeset
|
282 |
|
e0e720fce465
CmdLineParser refactored to allow both `--long-option=value` and `--long-option value` forms
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
20076
diff
changeset
|
283 |
parser parse:#('-l' 'v1'). |
e0e720fce465
CmdLineParser refactored to allow both `--long-option=value` and `--long-option value` forms
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
20076
diff
changeset
|
284 |
self assert: longOptionValue = 'v1'. |
e0e720fce465
CmdLineParser refactored to allow both `--long-option=value` and `--long-option value` forms
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
20076
diff
changeset
|
285 |
|
e0e720fce465
CmdLineParser refactored to allow both `--long-option=value` and `--long-option value` forms
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
20076
diff
changeset
|
286 |
parser parse:#('--long-option' 'v2'). |
e0e720fce465
CmdLineParser refactored to allow both `--long-option=value` and `--long-option value` forms
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
20076
diff
changeset
|
287 |
self assert: longOptionValue = 'v2'. |
e0e720fce465
CmdLineParser refactored to allow both `--long-option=value` and `--long-option value` forms
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
20076
diff
changeset
|
288 |
|
e0e720fce465
CmdLineParser refactored to allow both `--long-option=value` and `--long-option value` forms
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
20076
diff
changeset
|
289 |
"Created: / 29-06-2016 / 18:43:51 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
13402 | 290 |
! ! |
291 |
||
292 |
!CmdLineParserTest class methodsFor:'documentation'! |
|
293 |
||
13939 | 294 |
version |
17340 | 295 |
^'$Header: /cvs/stx/stx/libbasic/CmdLineParserTest.st,v 1.4 2015-01-29 19:22:05 cg Exp $' |
20076
ff2f4d06a2fa
CmdLineParser refactored and added an option to ignore unknown options
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
19988
diff
changeset
|
296 |
! |
ff2f4d06a2fa
CmdLineParser refactored and added an option to ignore unknown options
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
19988
diff
changeset
|
297 |
|
ff2f4d06a2fa
CmdLineParser refactored and added an option to ignore unknown options
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
19988
diff
changeset
|
298 |
version_HG |
ff2f4d06a2fa
CmdLineParser refactored and added an option to ignore unknown options
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
19988
diff
changeset
|
299 |
|
ff2f4d06a2fa
CmdLineParser refactored and added an option to ignore unknown options
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
19988
diff
changeset
|
300 |
^ '$Changeset: <not expanded> $' |
13402 | 301 |
! ! |
17340 | 302 |