13402
|
1 |
"
|
13938
|
2 |
COPYRIGHT (c) 2006 by eXept Software AG
|
13402
|
3 |
All Rights Reserved
|
|
4 |
|
13938
|
5 |
This software is furnished under a license and may be used
|
|
6 |
only in accordance with the terms of that license and with the
|
|
7 |
inclusion of the above copyright notice. This software may not
|
|
8 |
be provided or otherwise made available to, or used by, any
|
|
9 |
other person. No title to or ownership of the software is
|
|
10 |
hereby transferred.
|
13402
|
11 |
"
|
|
12 |
"{ Package: 'stx:libbasic' }"
|
|
13 |
|
|
14 |
Object subclass:#CmdLineOption
|
|
15 |
instanceVariableNames:'action description short long'
|
|
16 |
classVariableNames:''
|
|
17 |
poolDictionaries:''
|
|
18 |
category:'System-Support-Command line'
|
|
19 |
!
|
|
20 |
|
|
21 |
!CmdLineOption class methodsFor:'documentation'!
|
|
22 |
|
|
23 |
copyright
|
|
24 |
"
|
13938
|
25 |
COPYRIGHT (c) 2006 by eXept Software AG
|
13402
|
26 |
All Rights Reserved
|
|
27 |
|
13938
|
28 |
This software is furnished under a license and may be used
|
|
29 |
only in accordance with the terms of that license and with the
|
|
30 |
inclusion of the above copyright notice. This software may not
|
|
31 |
be provided or otherwise made available to, or used by, any
|
|
32 |
other person. No title to or ownership of the software is
|
|
33 |
hereby transferred.
|
|
34 |
"
|
|
35 |
!
|
13482
|
36 |
|
13938
|
37 |
optionsFor: anObject
|
13482
|
38 |
|
13938
|
39 |
"Returns a collection of command line options for
|
|
40 |
given object."
|
|
41 |
|
|
42 |
^anObject class allSelectors
|
|
43 |
select:[:sel|sel startsWith: 'cmdlineOption']
|
|
44 |
thenCollect:[:sel|anObject perform: sel].
|
13402
|
45 |
! !
|
|
46 |
|
|
47 |
!CmdLineOption methodsFor:'accessing'!
|
|
48 |
|
|
49 |
action
|
|
50 |
^ action
|
|
51 |
|
|
52 |
"Created: / 28-01-2009 / 11:49:55 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
|
53 |
!
|
|
54 |
|
|
55 |
action:aBlockOrMessageSend
|
|
56 |
|
|
57 |
aBlockOrMessageSend numArgs > 1 ifTrue:
|
|
58 |
[CmdLineOptionError raiseErrorString: 'Action must be zero-or-one arg block/message send'].
|
|
59 |
action := aBlockOrMessageSend.
|
|
60 |
|
|
61 |
"Created: / 28-01-2009 / 11:49:55 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
|
62 |
"Modified: / 16-06-2009 / 15:46:54 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
|
63 |
!
|
|
64 |
|
|
65 |
description
|
|
66 |
^ description
|
|
67 |
|
|
68 |
"Created: / 28-01-2009 / 11:49:55 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
|
69 |
!
|
|
70 |
|
|
71 |
description:aString
|
|
72 |
description := aString.
|
|
73 |
|
|
74 |
"Created: / 28-01-2009 / 11:49:55 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
|
75 |
!
|
|
76 |
|
|
77 |
long
|
|
78 |
^ long
|
|
79 |
!
|
|
80 |
|
|
81 |
long:aString
|
|
82 |
long := aString.
|
|
83 |
!
|
|
84 |
|
|
85 |
short
|
|
86 |
^ short
|
|
87 |
!
|
|
88 |
|
|
89 |
short:aCharacterOrString
|
|
90 |
|
|
91 |
(aCharacterOrString isCharacter
|
|
92 |
and:[aCharacterOrString isAlphaNumeric])
|
|
93 |
ifTrue:[short := aCharacterOrString]
|
|
94 |
ifFalse:[self error: 'short option name should be alphanumeric character']
|
|
95 |
|
|
96 |
"Modified: / 29-05-2009 / 16:05:46 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
|
97 |
! !
|
|
98 |
|
|
99 |
!CmdLineOption methodsFor:'printing & storing'!
|
|
100 |
|
|
101 |
printOn: stream
|
|
102 |
|
|
103 |
super printOn: stream.
|
|
104 |
stream nextPut:$(.
|
|
105 |
short ifNotNil:[stream nextPut: $-; nextPut: short].
|
|
106 |
(short notNil and: [long notNil]) ifTrue:[stream nextPut:$|].
|
|
107 |
long ifNotNil:[stream nextPut: $-; nextPut: $-; nextPutAll: long].
|
|
108 |
stream nextPut:$)
|
|
109 |
|
|
110 |
"Created: / 08-06-2009 / 14:48:59 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
|
111 |
! !
|
|
112 |
|
|
113 |
!CmdLineOption methodsFor:'processing'!
|
|
114 |
|
|
115 |
process
|
|
116 |
|
|
117 |
action value
|
|
118 |
|
|
119 |
"Created: / 08-06-2009 / 14:35:01 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
|
120 |
!
|
|
121 |
|
|
122 |
process: value
|
|
123 |
|
|
124 |
action value: value
|
|
125 |
|
|
126 |
"Created: / 08-06-2009 / 14:35:08 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
|
127 |
! !
|
|
128 |
|
|
129 |
!CmdLineOption methodsFor:'queries'!
|
|
130 |
|
|
131 |
hasParam
|
|
132 |
|
|
133 |
^action numArgs = 1
|
|
134 |
|
|
135 |
"Created: / 08-06-2009 / 13:45:41 / Jan Vrany <vranyj1@fel.cvut.cz>"
|
|
136 |
! !
|
|
137 |
|
|
138 |
!CmdLineOption class methodsFor:'documentation'!
|
|
139 |
|
13938
|
140 |
version
|
|
141 |
^'$Header: /cvs/stx/stx/libbasic/CmdLineOption.st,v 1.3 2012-01-13 10:58:29 vrany Exp $'
|
13402
|
142 |
!
|
|
143 |
|
|
144 |
version_SVN
|
13938
|
145 |
^ '§Id: CmdLineOption.st 10737 2011-11-06 21:23:48Z vranyj1 §'
|
13402
|
146 |
! !
|