/
clish.xsd
296 lines (294 loc) · 12.4 KB
/
clish.xsd
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://mindginative.com/projects/zafu/XMLSchema" targetNamespace="http://mindginative.com/projects/zafu/XMLSchema">
<!--
***********************************************************
* Forward declare the main element identifiers
***********************************************************
-->
<xs:element name="CLISH_MODULE" type="clish_module_t"/>
<xs:element name="VIEW" type="view_t"/>
<xs:element name="COMMAND" type="command_t"/>
<xs:element name="STARTUP" type="startup_t"/>
<xs:element name="ACTION" type="action_t"/>
<xs:element name="OVERVIEW" type="overview_t"/>
<xs:element name="DETAIL" type="detail_t"/>
<xs:element name="PTYPE" type="ptype_t"/>
<xs:element name="PARAM" type="param_t"/>
<!--
***********************************************************
* <CLISH_MODULE> is the top level container.
* Any commands which are defined within this tag are global in scope
* i.e. they are visible from all views.
***********************************************************
-->
<xs:complexType name="clish_module_t">
<xs:sequence>
<xs:element ref="OVERVIEW" minOccurs="0"/>
<xs:element ref="STARTUP" minOccurs="0"/>
<xs:element ref="PTYPE" minOccurs="0" maxOccurs="unbounded"/>
<xs:element ref="COMMAND" minOccurs="0" maxOccurs="unbounded"/>
<xs:element ref="VIEW" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<!--
***********************************************************
* Identify some attribute groups
***********************************************************
-->
<xs:attributeGroup name="menu_item_g">
<xs:attribute name="name" type="xs:string" use="required"/>
<xs:attribute name="help" type="xs:string" use="required"/>
</xs:attributeGroup>
<!--
*******************************************************
* <PTYPE> is used to define the syntax for a parameter type.
*
* name - a textual name for this type. This name can be used to
* reference this type within a <PARAM? ptype attribute.
*
* help - a textual string which describes the syntax of this type.
* When a parameter is filled out incorrectly on the CLI, this
* text will be used to prompt the user to fill out the value
* correctly.
*
* pattern - A regular expression which defines the syntax of the type.
*
* method - The means by which the pattern is interpreted.
*
* "regexp" [default] - A POSIX regular expression.
*
* "integer" - A numeric definition "min..max"
*
* "select" - A list of possible values.
* The syntax of the string is of the form:
* "valueOne(ONE) valueTwo(TWO) valueThree(THREE)"
* where the text before the parethesis defines the syntax
* that the user must use, and the value within the parenthesis
* is the result expanded as a parameter value.
*
* preprocess - An optional directive to process the value entered before
* validating it. This can greatly simplify the regular expressions
* needed to match case insensitive values.
*
* "none" [default] - do nothing
*
* "toupper" - before validation convert to uppercase.
*
* "tolower" - before validation convert to lowercase.
*
********************************************************
-->
<xs:simpleType name="ptype_method_e">
<xs:restriction base="xs:string">
<xs:enumeration value="regexp"/>
<xs:enumeration value="integer"/>
<xs:enumeration value="select"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="ptype_preprocess_e">
<xs:restriction base="xs:string">
<xs:enumeration value="none"/>
<xs:enumeration value="toupper"/>
<xs:enumeration value="tolower"/>
</xs:restriction>
</xs:simpleType>
<xs:complexType name="ptype_t">
<xs:attributeGroup ref="menu_item_g"/>
<xs:attribute name="pattern" type="xs:string"/>
<xs:attribute name="method" type="ptype_method_e" use="optional" default="regexp"/>
<xs:attribute name="preprocess" type="ptype_preprocess_e" use="optional" default="none"/>
</xs:complexType>
<!--
*******************************************************
* <VIEW> defines the contents of a specific CLI view.
*
* name - a textual name for the view
*
* prompt - a textual definition of the prompt to be
* used whilst in this view.
* NB. The prompt may contain environment
* or dynamic variables which are expanded
* before display.
********************************************************
-->
<xs:complexType name="view_t">
<xs:sequence>
<xs:element ref="COMMAND" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="name" type="xs:string" use="required"/>
<xs:attribute name="prompt" type="xs:string" use="optional"/>
</xs:complexType>
<!--
*******************************************************
* <STARTUP> is used to define what happens when the CLI
* is started. Any text held in a <DETAIL> sub-element will
* be used as banner text, then any defined <ACTION> will be
* executed. This action may provide Message Of The Day (MOTD)
* type behaviour.
*
* view - defines the view which will be transitioned to, on
* successful execution of any <ACTION> tag.
*
* [viewid] - defined the new value of the ${VIEWID} variable to
* be used if a transition to a new view occurs.
********************************************************
-->
<xs:complexType name="startup_t">
<xs:sequence>
<xs:element ref="DETAIL" minOccurs="0"/>
<xs:element ref="ACTION" minOccurs="0"/>
</xs:sequence>
<xs:attribute name="view" type="xs:string" use="required"/>
<xs:attribute name="viewid" type="xs:string" use="optional"/>
</xs:complexType>
<!--
*******************************************************
* <COMMAND> is used to define a command within the CLI.
*
* name - a textual name for this command. (This may contain
* spaces e.g. "display acl")
*
* help - a textual string which describes the purpose of the
* command.
*
* [view] - defines the view which will be transitioned to, on
* successful execution of any <ACTION> tag. By default the
* current view stays in scope.
*
* [viewid] - defined the new value of the ${VIEWID} variable to
* be used if a transition to a new view occurs. By default
* the viewid will retain it's current value.
*
* [access] - defines the user group/level to which execution of this
* command is restricted. By default there is no restriction.
* The exact interpretation of this field is dependant on the
* client of libclish but for example the clish and tclish
* applications map this to the UNIX user groups.
*
* [escape_chars] - defines the characters which will be escaped (e.g. \$) before
* being expanded as a variable. By default the following
* characters will be escaped `|$<>&()#
*
* [args] - defines a parameter name to be used to gather the rest of the
* command line after the formally defined parameters
* (PARAM elements). The formatting of this parameter is a raw
* string containing as many words as there are on the rest of the
* command line.
*
* [args_help] - a textual string which describes the purpose of the 'args'
* parameter. If the "args" attribute is given then this MUST be
* given also.
*
*
********************************************************
-->
<xs:complexType name="command_t">
<xs:sequence>
<xs:element ref="DETAIL" minOccurs="0"/>
<xs:element ref="PARAM" minOccurs="0" maxOccurs="unbounded"/>
<xs:element ref="ACTION" minOccurs="0"/>
</xs:sequence>
<xs:attributeGroup ref="menu_item_g"/>
<xs:attribute name="view" type="xs:string" use="optional"/>
<xs:attribute name="viewid" type="xs:string" use="optional"/>
<xs:attribute name="access" type="xs:string" use="optional"/>
<xs:attribute name="args" type="xs:string" use="optional"/>
<xs:attribute name="args_help" type="xs:string" use="optional"/>
<xs:attribute name="escape_chars" type="xs:string" use="optional"/>
</xs:complexType>
<!--
*******************************************************
* <PARAM> This tag is used to define a parameter for a command.
*
* name - a textual name for this parameter.
*
* help - a textual string which describes the purpose of the
* parameter.
*
* ptype - Reference to a PTYPE name. This parameter will be
* validated against the syntax specified for that type.
* The special value of "" indicates the parameter is a boolean flag.
* The verbatim presence of the texual name on the command line
* simply controls the conditional variable expansion for this
* parameter.
*
* [prefix] - defines the prefix for an optional parameter. A prefix
* with this value on the command line will signify the presence
* of an additional argument which will be validated as the
* value of this parameter.
*
* [default] - defines a default value for a parameter. Any parameters
* at the end of command line which have default values need
* not explicitly be entered.
********************************************************
-->
<xs:complexType name="param_t">
<xs:attributeGroup ref="menu_item_g"/>
<xs:attribute name="ptype" type="xs:string" use="required"/>
<xs:attribute name="default" type="xs:string" use="optional"/>
<xs:attribute name="prefix" type="xs:string" use="optional"/>
</xs:complexType>
<!--
********************************************************
* <ACTION> specifies the action to be taken for
* a command.
*
* The textual contents of the tag are variable expanded
* (environment, dynamic and parameter) the the resulting
* text is interpreted by the client's script interpreter.
*
* In addition the optional 'builtin' attribute can specify
* the name of an internal command which will be invoked
* instead of the client's script handler.
*
* NB. for security reasons any special shell characters
* (e.g. $|<>`) are escaped before evaluation.
*
* [builtin] - specify the name of an internally registered
* function. The content of the ACTION tag is
* taken as the arguments to this builtin function.
********************************************************
-->
<xs:complexType name="action_t">
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="builtin" type="xs:string" use="optional"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
<!--
********************************************************
* <OVERVIEW> specifies a textual description of the shell.
*
* This should provide instructions about key bindings and
* escape sequences which can be used in the CLI.
*
********************************************************
-->
<xs:simpleType name="overview_t">
<xs:restriction base="xs:string">
<xs:whiteSpace value="preserve"/>
</xs:restriction>
</xs:simpleType>
<!--
********************************************************
* <DETAIL> specifies a textual description.
*
* This may be used within the scope of a <COMMAND>
* element, in which case it would typically contain
* detailed usage instructions including examples.
*
* This may also be used within the scope of a <STARTUP>
* element, in which case the text is used as the banner
* details which are displayed on shell startup. This is
* shown before any specified <ACTION> is executed.
*
* This text may also be used in the production of user manuals.
********************************************************
-->
<xs:simpleType name="detail_t">
<xs:restriction base="xs:string">
<xs:whiteSpace value="preserve"/>
</xs:restriction>
</xs:simpleType>
</xs:schema>