-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathklish.xsd
440 lines (406 loc) · 17.6 KB
/
klish.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
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://clish.sourceforge.net/XMLSchema" targetNamespace="http://clish.sourceforge.net/XMLSchema">
<xs:annotation>
<xs:appinfo>XML schema for klish configuration files</xs:appinfo>
<xs:documentation xml:lang="en">
The klish utility uses XML files for configuration. This schema
allows to validate klish XML files. To check XML files use the
following command:
'xmllint --schema /path/to/klish.xsd --noout *.xml'
</xs:documentation>
<xs:documentation xml:lang="ru">
Утилита klish использует формат XML для своих конфигурационных
файлов. Схема позволяет проверить эти конфигурационные XML файлы
на правильность. Следующая команда выполнит проверку:
'xmllint --schema /path/to/klish.xsd --noout *.xml'
</xs:documentation>
</xs:annotation>
<xs:element name="KLISH" type="klish_t"/>
<xs:element name="PLUGIN" type="plugin_t"/>
<xs:element name="HOTKEY" type="hotkey_t"/>
<xs:element name="ACTION" type="action_t"/>
<xs:element name="ENTRY" type="entry_t"/>
<xs:element name="VIEW" type="view_t"/> <!-- Wrapper -->
<xs:element name="COMMAND" type="command_t"/> <!-- Wrapper -->
<xs:element name="FILTER" type="command_t"/> <!-- Wrapper -->
<xs:element name="COND" type="command_t"/> <!-- Wrapper -->
<xs:element name="COMPL" type="command_t"/> <!-- Wrapper -->
<xs:element name="HELP" type="command_t"/> <!-- Wrapper -->
<xs:element name="PROMPT" type="command_t"/> <!-- Wrapper -->
<xs:element name="PTYPE" type="ptype_t"/> <!-- Wrapper -->
<xs:element name="PARAM" type="param_t"/> <!-- Wrapper -->
<xs:element name="SWITCH" type="param_t"/> <!-- Wrapper -->
<xs:element name="SEQ" type="param_t"/> <!-- Wrapper -->
<!--
*******************************************************
* <KLISH> is a top level container.
********************************************************
-->
<xs:group name="klish_group_t">
<xs:choice>
<xs:element ref="PLUGIN" minOccurs="0" maxOccurs="unbounded"/>
<xs:element ref="HOTKEY" minOccurs="0" maxOccurs="unbounded"/>
<xs:element ref="ENTRY" minOccurs="0" maxOccurs="unbounded"/>
<xs:element ref="PTYPE" minOccurs="0" maxOccurs="unbounded"/>
<xs:element ref="VIEW" minOccurs="0" maxOccurs="unbounded"/>
</xs:choice>
</xs:group>
<xs:complexType name="klish_t">
<xs:annotation>
<xs:documentation xml:lang="en">
'KLISH' is the top level container.
</xs:documentation>
<xs:documentation xml:lang="ru">
Тег 'KLISH' - контейнер верхнего уровня. Все остальные
теги должны быть вложенными.
</xs:documentation>
</xs:annotation>
<!-- Any order of tags and any number -->
<xs:sequence>
<xs:group ref="klish_group_t" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<!--
*******************************************************
* <PLUGIN> is used to dynamically load plugins.
* Plugin contains symbols that can be used for ACTIONs.
*
* name - Plugin name. If "file" attribute is not specified then plugin's
* filename is autogenerated as "kplugin-<name>.so".
*
* [id] - Internal plugin name for references. Can be the same as "name".
*
* [file] - File name to use if standard autogenerated filename (using "name"
* field) is not appropriate.
*
* The content of PLUGIN tag can be used as a config file for this plugin.
* Parsing of this content must be implemented within plugin's init.
*
********************************************************
-->
<xs:complexType name="plugin_t">
<xs:annotation>
<xs:documentation xml:lang="en">
Load plugin with symbols (functions).
</xs:documentation>
<xs:documentation xml:lang="ru">
Загружает плугин для использования определяемых в нем
символов (функций).
</xs:documentation>
</xs:annotation>
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="name" type="xs:string" use="required"/>
<xs:attribute name="id" type="xs:string" use="optional"/>
<xs:attribute name="file" type="xs:string" use="optional"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
<!--
*******************************************************
* <HOTKEY> is used to define hotkey actions
*
* key - Hot-key
*
* cmd - Text string defines command to execute on pressing hot-key. It's like
* a common user CLI input. This string will be interpreted by CLI engine.
*
********************************************************
-->
<xs:complexType name="hotkey_t">
<xs:attribute name="key" type="xs:string" use="required"/>
<xs:attribute name="cmd" type="xs:string" use="required"/>
</xs:complexType>
<!--
********************************************************
* <ACTION> specifies the action to be taken for
* a command.
*
* In addition the optional 'sym' attribute can specify
* the name of an internal command which will be invoked
* to handle script.
*
* [sym="<symbol>"] - specify the name of an internally registered
* function (symbol). The content of the ACTION tag is
* taken as the arguments to this function. Plugins can define
* these symbols. The "<symbol>" can be defined as "sym@plugin" i.e.
* parental plugin can be defined explicitly.
*
* [lock="<name>"] - Named lock. It will use special lockfile while
* action execution.
*
* [interrupt="true/false"] - The boolean field that specify that action can be
* be interrupted by Ctrl^C. Default is false. Ignored for non-interactive
* actions.
*
* [interactive="true/false"] - Is action interactive.
*
* [exec_on="fail/success/always/never"] - ACTION's execution depends on
* return code of previous elements of ACTION chain. If the
* condition is not met then ACTION will not be executed. The "always"
* value means that ACTION will be always executed and chain return
* code will be ignored. Default is "success".
*
* [update_retcode="true/false"] - The chain return value can be updated
* by current ACTION's return code or ACTION's return code can be ignored.
* Default is "true".
*
* [permanent="true/false"] - The klish can be invoked with dry-run option. In
* this case all ACTIONs will be not actually executed but will always
* return success. But some actions like navigation is necessary to be
* executed in any case. Permanent flag will inform engine to always
* execute ACTION.
*
* [sync="true/false"] - Common behaviour is to fork() process before ACTION
* execution. But ACTION may be executed in-place (without fork()) if sync
* flag is set to true. It's not recommended to use sync ACTIONs widely.
* It's usefull for small fast functions only.
*
********************************************************
-->
<xs:simpleType name="action_cond_t">
<xs:restriction base="xs:string">
<xs:enumeration value="fail"/>
<xs:enumeration value="success"/>
<xs:enumeration value="always"/>
<xs:enumeration value="never"/>
</xs:restriction>
</xs:simpleType>
<xs:complexType name="action_t">
<xs:simpleContent>
<xs:extension base="xs:string">
<xs:attribute name="sym" type="xs:string" use="optional"/>
<xs:attribute name="lock" type="xs:string" use="optional"/>
<xs:attribute name="interrupt" type="xs:boolean" use="optional" default="false"/>
<xs:attribute name="interactive" type="xs:boolean" use="optional" default="false"/>
<xs:attribute name="exec_on" type="action_cond_t" use="optional" default="success"/>
<xs:attribute name="update_retcode" type="xs:boolean" use="optional" default="true"/>
<xs:attribute name="permanent" type="xs:boolean" use="optional" default="false"/>
<xs:attribute name="sync" type="xs:boolean" use="optional" default="false"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
<!--
*******************************************************
* <ENTRY> This tag is used to define wide class of elements.
*
* name - A text name for entry.
*
* [help] - A text string which describes the purpose of the entry.
*
* [container="true/false"] - If entry is container. Container entry can't
* have parsable argument i.e. only container's children can be considered
* as a candidates to be a appropriate instance for parsed argument.
* For example VIEW is a container. It just structurizes commands but
* are not commands itself. Another example of container is a SWITCH.
* It describes parsing of child elements but has no special keyword
* while user typing.
*
* [mode] - Entry mode. It can be "sequence", "switch", "empty". Default is
* "sequence".
*
* [purpose] - Purpose of entry. It can be "common", "ptype", "prompt", "cond",
* "completion", "help". Default is "common". Another "purposes" are
* processed in a special ways.
*
* [min="<num>"] - Min number of entry occurence while user input parsing.
* Default is 1.
*
* [max="<num>"] - Max number of entry occurence while user input parsing.
* Default is 1.
*
* [ref="<reference>"] - Entry can reference another entry.
*
* [value="<val>"] - defines the user's value for subcommand. If this option
* is defined the entered parameter will be compared to this
* value instead the "name" field. If this field is defined
* the mode of PARAM will be forced to "subcommand". The
* feature is implemented to support subcommands with the
* same names.
*
* [restore="true/false"] - Restore (or not) hierarchy level of executed
* entry. Default is "false".
*
* [order="true/false"] - If order="true" then user can't enter previously declared
* optional parameters after current validated parameter.
* The allowed values is "true" or "false". It's false by default.
*
* [filter="true/false"] - Developer can define 'filter' command to filter stdout
* of piped ("|") commands. Filter can't contain 'sync' ACTIONs. It will be
* always fork()-ed. Only filters can be on the right hand to pipe "|".
* Consider filters as a special type of commands.
*
********************************************************
-->
<xs:simpleType name="entry_mode_t">
<xs:restriction base="xs:string">
<xs:enumeration value="sequence"/>
<xs:enumeration value="switch"/>
<xs:enumeration value="empty"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="entry_purpose_t">
<xs:restriction base="xs:string">
<xs:enumeration value="common"/>
<xs:enumeration value="ptype"/>
<xs:enumeration value="prompt"/>
<xs:enumeration value="cond"/>
<xs:enumeration value="completion"/>
<xs:enumeration value="help"/>
</xs:restriction>
</xs:simpleType>
<xs:group name="entry_group_t">
<xs:choice>
<xs:element ref="HOTKEY" minOccurs="0" maxOccurs="unbounded"/>
<xs:element ref="ACTION" minOccurs="0" maxOccurs="unbounded"/>
<xs:element ref="ENTRY" minOccurs="0" maxOccurs="unbounded"/>
<xs:element ref="PTYPE" minOccurs="0" maxOccurs="unbounded"/>
<xs:element ref="VIEW" minOccurs="0" maxOccurs="unbounded"/>
<xs:element ref="COMMAND" minOccurs="0" maxOccurs="unbounded"/>
<xs:element ref="FILTER" minOccurs="0" maxOccurs="unbounded"/>
<xs:element ref="PARAM" minOccurs="0" maxOccurs="unbounded"/>
<xs:element ref="COND" minOccurs="0" maxOccurs="unbounded"/>
<xs:element ref="COMPL" minOccurs="0" maxOccurs="unbounded"/>
<xs:element ref="HELP" minOccurs="0" maxOccurs="unbounded"/>
<xs:element ref="PROMPT" minOccurs="0" maxOccurs="unbounded"/>
<xs:element ref="SWITCH" minOccurs="0" maxOccurs="unbounded"/>
<xs:element ref="SEQ" minOccurs="0" maxOccurs="unbounded"/>
</xs:choice>
</xs:group>
<xs:complexType name="entry_t">
<!-- Any order of tags and any number -->
<xs:sequence>
<xs:group ref="entry_group_t" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="name" type="xs:string" use="required"/>
<xs:attribute name="help" type="xs:string" use="optional"/>
<xs:attribute name="container" type="xs:boolean" use="optional" default="false"/>
<xs:attribute name="mode" type="entry_mode_t" use="optional" default="switch"/>
<xs:attribute name="purpose" type="entry_purpose_t" use="optional" default="common"/>
<xs:attribute name="min" type="xs:string" use="optional" default="1"/>
<xs:attribute name="max" type="xs:string" use="optional" default="1"/>
<xs:attribute name="ref" type="xs:string" use="optional"/>
<xs:attribute name="value" type="xs:string" use="optional"/>
<xs:attribute name="restore" type="xs:boolean" use="optional" default="false"/>
<xs:attribute name="order" type="xs:boolean" use="optional" default="false"/>
<xs:attribute name="filter" type="xs:boolean" use="optional" default="false"/>
</xs:complexType>
<!--
*******************************************************
* <PTYPE> is used to define the syntax for a parameter type.
*
* See ENTRY tag for attributes description.
*
********************************************************
-->
<xs:group name="ptype_group_t">
<xs:choice>
<xs:element ref="ACTION" minOccurs="0" maxOccurs="unbounded"/>
<xs:element ref="ENTRY" minOccurs="0" maxOccurs="unbounded"/>
<xs:element ref="COND" minOccurs="0" maxOccurs="unbounded"/>
<xs:element ref="COMPL" minOccurs="0" maxOccurs="unbounded"/>
<xs:element ref="HELP" minOccurs="0" maxOccurs="unbounded"/>
</xs:choice>
</xs:group>
<xs:complexType name="ptype_t">
<xs:sequence>
<xs:group ref="ptype_group_t" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="name" type="xs:string" use="optional"/>
<xs:attribute name="help" type="xs:string" use="optional"/>
<xs:attribute name="ref" type="xs:string" use="optional"/>
<xs:attribute name="value" type="xs:string" use="optional"/>
</xs:complexType>
<!--
*******************************************************
* <VIEW> defines the contents of a specific CLI view.
*
* See ENTRY tag for attributes description.
*
********************************************************
-->
<xs:group name="view_group_t">
<xs:choice>
<xs:element ref="HOTKEY" minOccurs="0" maxOccurs="unbounded"/>
<xs:element ref="ENTRY" minOccurs="0" maxOccurs="unbounded"/>
<xs:element ref="PTYPE" minOccurs="0" maxOccurs="unbounded"/>
<xs:element ref="VIEW" minOccurs="0" maxOccurs="unbounded"/>
<xs:element ref="COMMAND" minOccurs="0" maxOccurs="unbounded"/>
<xs:element ref="FILTER" minOccurs="0" maxOccurs="unbounded"/>
<xs:element ref="PARAM" minOccurs="0" maxOccurs="unbounded"/>
<xs:element ref="COND" minOccurs="0" maxOccurs="unbounded"/>
<xs:element ref="COMPL" minOccurs="0" maxOccurs="unbounded"/>
<xs:element ref="HELP" minOccurs="0" maxOccurs="unbounded"/>
<xs:element ref="PROMPT" minOccurs="0" maxOccurs="unbounded"/>
<xs:element ref="SWITCH" minOccurs="0" maxOccurs="unbounded"/>
<xs:element ref="SEQ" minOccurs="0" maxOccurs="unbounded"/>
</xs:choice>
</xs:group>
<xs:complexType name="view_t">
<xs:sequence>
<xs:group ref="view_group_t" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="name" type="xs:string" use="required"/>
<xs:attribute name="help" type="xs:string" use="optional"/>
<xs:attribute name="ref" type="xs:string" use="optional"/>
</xs:complexType>
<!--
*******************************************************
* <PARAM> This tag is used to define a parameter for a command.
*
* See ENTRY tag for attributes description.
*
********************************************************
-->
<xs:group name="param_group_t">
<xs:choice>
<xs:element ref="ACTION" minOccurs="0" maxOccurs="unbounded"/>
<xs:element ref="ENTRY" minOccurs="0" maxOccurs="unbounded"/>
<xs:element ref="PTYPE" minOccurs="0" maxOccurs="unbounded"/>
<xs:element ref="VIEW" minOccurs="0" maxOccurs="unbounded"/>
<xs:element ref="COMMAND" minOccurs="0" maxOccurs="unbounded"/>
<xs:element ref="FILTER" minOccurs="0" maxOccurs="unbounded"/>
<xs:element ref="PARAM" minOccurs="0" maxOccurs="unbounded"/>
<xs:element ref="COND" minOccurs="0" maxOccurs="unbounded"/>
<xs:element ref="COMPL" minOccurs="0" maxOccurs="unbounded"/>
<xs:element ref="HELP" minOccurs="0" maxOccurs="unbounded"/>
<xs:element ref="SWITCH" minOccurs="0" maxOccurs="unbounded"/>
<xs:element ref="SEQ" minOccurs="0" maxOccurs="unbounded"/>
</xs:choice>
</xs:group>
<xs:complexType name="param_t">
<!-- Any order of tags and any number -->
<xs:sequence>
<xs:group ref="param_group_t" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="name" type="xs:string" use="required"/>
<xs:attribute name="help" type="xs:string" use="optional"/>
<xs:attribute name="ptype" type="xs:string" use="optional"/>
<xs:attribute name="mode" type="entry_mode_t" use="optional" default="sequence"/>
<xs:attribute name="min" type="xs:string" use="optional" default="1"/>
<xs:attribute name="max" type="xs:string" use="optional" default="1"/>
<xs:attribute name="ref" type="xs:string" use="optional"/>
<xs:attribute name="value" type="xs:string" use="optional"/>
<xs:attribute name="order" type="xs:boolean" use="optional" default="false"/>
</xs:complexType>
<!--
*******************************************************
* <COMMAND> is used to define a command within the CLI.
*
* See ENTRY tag for attributes description.
*
********************************************************
-->
<xs:complexType name="command_t">
<!-- Any order of tags and any number -->
<xs:sequence>
<xs:group ref="entry_group_t" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="name" type="xs:string" use="optional"/>
<xs:attribute name="help" type="xs:string" use="optional"/>
<xs:attribute name="mode" type="entry_mode_t" use="optional" default="sequence"/>
<xs:attribute name="ref" type="xs:string" use="optional"/>
<xs:attribute name="value" type="xs:string" use="optional"/>
<xs:attribute name="restore" type="xs:boolean" use="optional" default="false"/>
</xs:complexType>
</xs:schema>