klish.xsd 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://clish.sourceforge.net/XMLSchema" targetNamespace="http://clish.sourceforge.net/XMLSchema">
  3. <xs:annotation>
  4. <xs:appinfo>XML schema for klish configuration files</xs:appinfo>
  5. <xs:documentation xml:lang="en">
  6. The klish utility uses XML files for configuration. This schema
  7. allows to validate klish XML files. To check XML files use the
  8. following command:
  9. 'xmllint --schema /path/to/klish.xsd --noout *.xml'
  10. </xs:documentation>
  11. <xs:documentation xml:lang="ru">
  12. Утилита klish использует формат XML для своих конфигурационных
  13. файлов. Схема позволяет проверить эти конфигурационные XML файлы
  14. на правильность. Следующая команда выполнит проверку:
  15. 'xmllint --schema /path/to/klish.xsd --noout *.xml'
  16. </xs:documentation>
  17. </xs:annotation>
  18. <xs:element name="KLISH" type="klish_t"/>
  19. <xs:element name="PLUGIN" type="plugin_t"/>
  20. <xs:element name="HOTKEY" type="hotkey_t"/>
  21. <xs:element name="ACTION" type="action_t"/>
  22. <xs:element name="ENTRY" type="entry_t"/>
  23. <xs:element name="VIEW" type="view_t"/> <!-- Wrapper -->
  24. <xs:element name="COMMAND" type="command_t"/> <!-- Wrapper -->
  25. <xs:element name="FILTER" type="command_t"/> <!-- Wrapper -->
  26. <xs:element name="COND" type="command_t"/> <!-- Wrapper -->
  27. <xs:element name="COMPL" type="command_t"/> <!-- Wrapper -->
  28. <xs:element name="HELP" type="command_t"/> <!-- Wrapper -->
  29. <xs:element name="PTYPE" type="ptype_t"/> <!-- Wrapper -->
  30. <xs:element name="PARAM" type="param_t"/> <!-- Wrapper -->
  31. <xs:element name="SWITCH" type="param_t"/> <!-- Wrapper -->
  32. <xs:element name="MULTI" type="param_t"/> <!-- Wrapper -->
  33. <!--
  34. *******************************************************
  35. * <KLISH> is a top level container.
  36. ********************************************************
  37. -->
  38. <xs:group name="klish_group_t">
  39. <xs:choice>
  40. <xs:element ref="PLUGIN" minOccurs="0" maxOccurs="unbounded"/>
  41. <xs:element ref="HOTKEY" minOccurs="0" maxOccurs="unbounded"/>
  42. <xs:element ref="ENTRY" minOccurs="0" maxOccurs="unbounded"/>
  43. <xs:element ref="PTYPE" minOccurs="0" maxOccurs="unbounded"/>
  44. <xs:element ref="VIEW" minOccurs="0" maxOccurs="unbounded"/>
  45. </xs:choice>
  46. </xs:group>
  47. <xs:complexType name="klish_t">
  48. <xs:annotation>
  49. <xs:documentation xml:lang="en">
  50. 'KLISH' is the top level container.
  51. </xs:documentation>
  52. <xs:documentation xml:lang="ru">
  53. Тег 'KLISH' - контейнер верхнего уровня. Все остальные
  54. теги должны быть вложенными.
  55. </xs:documentation>
  56. </xs:annotation>
  57. <!-- Any order of tags and any number -->
  58. <xs:sequence>
  59. <xs:group ref="klish_group_t" minOccurs="0" maxOccurs="unbounded"/>
  60. </xs:sequence>
  61. </xs:complexType>
  62. <!--
  63. *******************************************************
  64. * <PLUGIN> is used to dynamically load plugins.
  65. * Plugin contains symbols that can be used for ACTIONs.
  66. *
  67. * name - Plugin name. If "file" attribute is not specified then plugin's
  68. * filename is autogenerated as "kplugin-<name>.so".
  69. *
  70. * [id] - Internal plugin name for references. Can be the same as "name".
  71. *
  72. * [file] - File name to use if standard autogenerated filename (using "name"
  73. * field) is not appropriate.
  74. *
  75. * The content of PLUGIN tag can be used as a config file for this plugin.
  76. * Parsing of this content must be implemented within plugin's init.
  77. *
  78. ********************************************************
  79. -->
  80. <xs:complexType name="plugin_t">
  81. <xs:annotation>
  82. <xs:documentation xml:lang="en">
  83. Load plugin with symbols (functions).
  84. </xs:documentation>
  85. <xs:documentation xml:lang="ru">
  86. Загружает плугин для использования определяемых в нем
  87. символов (функций).
  88. </xs:documentation>
  89. </xs:annotation>
  90. <xs:simpleContent>
  91. <xs:extension base="xs:string">
  92. <xs:attribute name="name" type="xs:string" use="required"/>
  93. <xs:attribute name="id" type="xs:string" use="optional"/>
  94. <xs:attribute name="file" type="xs:string" use="optional"/>
  95. </xs:extension>
  96. </xs:simpleContent>
  97. </xs:complexType>
  98. <!--
  99. *******************************************************
  100. * <HOTKEY> is used to define hotkey actions
  101. *
  102. * key - Hot-key
  103. *
  104. * cmd - Text string defines command to execute on pressing hot-key. It's like
  105. * a common user CLI input. This string will be interpreted by CLI engine.
  106. *
  107. ********************************************************
  108. -->
  109. <xs:complexType name="hotkey_t">
  110. <xs:attribute name="key" type="xs:string" use="required"/>
  111. <xs:attribute name="cmd" type="xs:string" use="required"/>
  112. </xs:complexType>
  113. <!--
  114. ********************************************************
  115. * <ACTION> specifies the action to be taken for
  116. * a command.
  117. *
  118. * In addition the optional 'sym' attribute can specify
  119. * the name of an internal command which will be invoked
  120. * to handle script.
  121. *
  122. * [sym="<symbol>"] - specify the name of an internally registered
  123. * function (symbol). The content of the ACTION tag is
  124. * taken as the arguments to this function. Plugins can define
  125. * these symbols. The "<symbol>" can be defined as "sym@plugin" i.e.
  126. * parental plugin can be defined explicitly.
  127. *
  128. * [lock="<name>"] - Named lock. It will use special lockfile while
  129. * action execution.
  130. *
  131. * [interrupt="true/false"] - The boolean field that specify that action can be
  132. * be interrupted by Ctrl^C. Default is false. Ignored for non-interactive
  133. * actions.
  134. *
  135. * [interactive="true/false"] - Is action interactive.
  136. *
  137. * [exec_on="fail/success/always/never"] - ACTION's execution depends on
  138. * return code of previous elements of ACTION chain. If the
  139. * condition is not met then ACTION will not be executed. The "always"
  140. * value means that ACTION will be always executed and chain return
  141. * code will be ignored. Default is "success".
  142. *
  143. * [update_retcode="true/false"] - The chain return value can be updated
  144. * by current ACTION's return code or ACTION's return code can be ignored.
  145. * Default is "true".
  146. *
  147. * [permanent="true/false"] - The klish can be invoked with dry-run option. In
  148. * this case all ACTIONs will be not actually executed but will always
  149. * return success. But some actions like navigation is necessary to be
  150. * executed in any case. Permanent flag will inform engine to always
  151. * execute ACTION.
  152. *
  153. * [sync="true/false"] - Common behaviour is to fork() process before ACTION
  154. * execution. But ACTION may be executed in-place (without fork()) if sync
  155. * flag is set to true. It's not recommended to use sync ACTIONs widely.
  156. * It's usefull for small fast functions only.
  157. *
  158. ********************************************************
  159. -->
  160. <xs:simpleType name="action_cond_t">
  161. <xs:restriction base="xs:string">
  162. <xs:enumeration value="fail"/>
  163. <xs:enumeration value="success"/>
  164. <xs:enumeration value="always"/>
  165. <xs:enumeration value="never"/>
  166. </xs:restriction>
  167. </xs:simpleType>
  168. <xs:complexType name="action_t">
  169. <xs:simpleContent>
  170. <xs:extension base="xs:string">
  171. <xs:attribute name="sym" type="xs:string" use="optional"/>
  172. <xs:attribute name="lock" type="xs:string" use="optional"/>
  173. <xs:attribute name="interrupt" type="xs:boolean" use="optional" default="false"/>
  174. <xs:attribute name="interactive" type="xs:boolean" use="optional" default="false"/>
  175. <xs:attribute name="exec_on" type="action_cond_t" use="optional" default="success"/>
  176. <xs:attribute name="update_retcode" type="xs:boolean" use="optional" default="true"/>
  177. <xs:attribute name="permanent" type="xs:boolean" use="optional" default="false"/>
  178. <xs:attribute name="sync" type="xs:boolean" use="optional" default="false"/>
  179. </xs:extension>
  180. </xs:simpleContent>
  181. </xs:complexType>
  182. <!--
  183. *******************************************************
  184. * <ENTRY> This tag is used to define wide class of elements.
  185. *
  186. * name - A text name for entry.
  187. *
  188. * [help] - A text string which describes the purpose of the entry.
  189. *
  190. * [container="true/false"] - If entry is container. Container entry can't
  191. * have parsable argument i.e. only container's children can be considered
  192. * as a candidates to be a appropriate instance for parsed argument.
  193. * For example VIEW is a container. It just structurizes commands but
  194. * are not commands itself. Another example of container is a SWITCH.
  195. * It describes parsing of child elements but has no special keyword
  196. * while user typing.
  197. *
  198. * [mode] - Entry mode. It can be "sequence", "switch", "empty". Default is
  199. * "sequence".
  200. *
  201. * [purpose] - Purpose of entry. It can be "common", "ptype", "prompt", "cond",
  202. * "completion", "help". Default is "common". Another "purposes" are
  203. * processed in a special ways.
  204. *
  205. * [min="<num>"] - Min number of entry occurence while user input parsing.
  206. * Default is 1.
  207. *
  208. * [max="<num>"] - Max number of entry occurence while user input parsing.
  209. * Default is 1.
  210. *
  211. * [ref="<reference>"] - Entry can reference another entry.
  212. *
  213. * [value="<val>"] - defines the user's value for subcommand. If this option
  214. * is defined the entered parameter will be compared to this
  215. * value instead the "name" field. If this field is defined
  216. * the mode of PARAM will be forced to "subcommand". The
  217. * feature is implemented to support subcommands with the
  218. * same names.
  219. *
  220. * [restore="true/false"] - Restore (or not) hierarchy level of executed
  221. * entry. Default is "false".
  222. *
  223. * [order="true/false"] - If order="true" then user can't enter previously declared
  224. * optional parameters after current validated parameter.
  225. * The allowed values is "true" or "false". It's false by default.
  226. *
  227. * [filter="true/false"] - Developer can define 'filter' command to filter stdout
  228. * of piped ("|") commands. Filter can't contain 'sync' ACTIONs. It will be
  229. * always fork()-ed. Only filters can be on the right hand to pipe "|".
  230. * Consider filters as a special type of commands.
  231. *
  232. ********************************************************
  233. -->
  234. <xs:simpleType name="entry_mode_t">
  235. <xs:restriction base="xs:string">
  236. <xs:enumeration value="sequence"/>
  237. <xs:enumeration value="switch"/>
  238. <xs:enumeration value="empty"/>
  239. </xs:restriction>
  240. </xs:simpleType>
  241. <xs:simpleType name="entry_purpose_t">
  242. <xs:restriction base="xs:string">
  243. <xs:enumeration value="common"/>
  244. <xs:enumeration value="ptype"/>
  245. <xs:enumeration value="prompt"/>
  246. <xs:enumeration value="cond"/>
  247. <xs:enumeration value="completion"/>
  248. <xs:enumeration value="help"/>
  249. </xs:restriction>
  250. </xs:simpleType>
  251. <xs:group name="entry_group_t">
  252. <xs:choice>
  253. <xs:element ref="HOTKEY" minOccurs="0" maxOccurs="unbounded"/>
  254. <xs:element ref="ACTION" minOccurs="0" maxOccurs="unbounded"/>
  255. <xs:element ref="ENTRY" minOccurs="0" maxOccurs="unbounded"/>
  256. <xs:element ref="PTYPE" minOccurs="0" maxOccurs="unbounded"/>
  257. <xs:element ref="VIEW" minOccurs="0" maxOccurs="unbounded"/>
  258. <xs:element ref="COMMAND" minOccurs="0" maxOccurs="unbounded"/>
  259. <xs:element ref="FILTER" minOccurs="0" maxOccurs="unbounded"/>
  260. <xs:element ref="PARAM" minOccurs="0" maxOccurs="unbounded"/>
  261. <xs:element ref="COND" minOccurs="0" maxOccurs="unbounded"/>
  262. <xs:element ref="COMPL" minOccurs="0" maxOccurs="unbounded"/>
  263. <xs:element ref="HELP" minOccurs="0" maxOccurs="unbounded"/>
  264. <xs:element ref="SWITCH" minOccurs="0" maxOccurs="unbounded"/>
  265. <xs:element ref="MULTI" minOccurs="0" maxOccurs="unbounded"/>
  266. </xs:choice>
  267. </xs:group>
  268. <xs:complexType name="entry_t">
  269. <!-- Any order of tags and any number -->
  270. <xs:sequence>
  271. <xs:group ref="entry_group_t" minOccurs="0" maxOccurs="unbounded"/>
  272. </xs:sequence>
  273. <xs:attribute name="name" type="xs:string" use="required"/>
  274. <xs:attribute name="help" type="xs:string" use="optional"/>
  275. <xs:attribute name="container" type="xs:boolean" use="optional" default="false"/>
  276. <xs:attribute name="mode" type="entry_mode_t" use="optional" default="switch"/>
  277. <xs:attribute name="purpose" type="entry_purpose_t" use="optional" default="common"/>
  278. <xs:attribute name="min" type="xs:string" use="optional" default="1"/>
  279. <xs:attribute name="max" type="xs:string" use="optional" default="1"/>
  280. <xs:attribute name="ref" type="xs:string" use="optional"/>
  281. <xs:attribute name="value" type="xs:string" use="optional"/>
  282. <xs:attribute name="restore" type="xs:boolean" use="optional" default="false"/>
  283. <xs:attribute name="order" type="xs:boolean" use="optional" default="false"/>
  284. <xs:attribute name="filter" type="xs:boolean" use="optional" default="false"/>
  285. </xs:complexType>
  286. <!--
  287. *******************************************************
  288. * <PTYPE> is used to define the syntax for a parameter type.
  289. *
  290. * name="<string>" - A textual name for this type. This name can be used to
  291. * reference this type within a PARAM's ptype attribute.
  292. *
  293. * [help="<string>"] - Help string.
  294. *
  295. ********************************************************
  296. -->
  297. <xs:group name="ptype_group_t">
  298. <xs:choice>
  299. <xs:element ref="ACTION" minOccurs="0" maxOccurs="unbounded"/>
  300. <xs:element ref="ENTRY" minOccurs="0" maxOccurs="unbounded"/>
  301. <xs:element ref="COND" minOccurs="0" maxOccurs="unbounded"/>
  302. <xs:element ref="COMPL" minOccurs="0" maxOccurs="unbounded"/>
  303. <xs:element ref="HELP" minOccurs="0" maxOccurs="unbounded"/>
  304. </xs:choice>
  305. </xs:group>
  306. <xs:complexType name="ptype_t">
  307. <xs:sequence>
  308. <xs:group ref="ptype_group_t" minOccurs="0" maxOccurs="unbounded"/>
  309. </xs:sequence>
  310. <xs:attribute name="name" type="xs:string" use="required"/>
  311. <xs:attribute name="help" type="xs:string" use="optional"/>
  312. <xs:attribute name="ref" type="xs:string" use="optional"/>
  313. <xs:attribute name="value" type="xs:string" use="optional"/>
  314. </xs:complexType>
  315. <!--
  316. *******************************************************
  317. * <VIEW> defines the contents of a specific CLI view.
  318. *
  319. * name - a textual name for the view
  320. *
  321. * prompt - a textual definition of the prompt to be
  322. * used whilst in this view.
  323. * NB. The prompt may contain environment
  324. * or dynamic variables which are expanded
  325. * before display.
  326. *
  327. * [access] - access rights
  328. *
  329. ********************************************************
  330. -->
  331. <xs:group name="view_group_t">
  332. <xs:choice>
  333. <xs:element ref="HOTKEY" minOccurs="0" maxOccurs="unbounded"/>
  334. <xs:element ref="ENTRY" minOccurs="0" maxOccurs="unbounded"/>
  335. <xs:element ref="PTYPE" minOccurs="0" maxOccurs="unbounded"/>
  336. <xs:element ref="VIEW" minOccurs="0" maxOccurs="unbounded"/>
  337. <xs:element ref="COMMAND" minOccurs="0" maxOccurs="unbounded"/>
  338. <xs:element ref="FILTER" minOccurs="0" maxOccurs="unbounded"/>
  339. <xs:element ref="PARAM" minOccurs="0" maxOccurs="unbounded"/>
  340. <xs:element ref="COND" minOccurs="0" maxOccurs="unbounded"/>
  341. <xs:element ref="COMPL" minOccurs="0" maxOccurs="unbounded"/>
  342. <xs:element ref="HELP" minOccurs="0" maxOccurs="unbounded"/>
  343. <xs:element ref="SWITCH" minOccurs="0" maxOccurs="unbounded"/>
  344. <xs:element ref="MULTI" minOccurs="0" maxOccurs="unbounded"/>
  345. </xs:choice>
  346. </xs:group>
  347. <xs:complexType name="view_t">
  348. <xs:sequence>
  349. <xs:group ref="view_group_t" minOccurs="0" maxOccurs="unbounded"/>
  350. </xs:sequence>
  351. <xs:attribute name="name" type="xs:string" use="required"/>
  352. <xs:attribute name="help" type="xs:string" use="optional"/>
  353. <xs:attribute name="ref" type="xs:string" use="optional"/>
  354. </xs:complexType>
  355. <!--
  356. *******************************************************
  357. * <PARAM> This tag is used to define a parameter for a command.
  358. *
  359. * name - a textual name for this parameter.
  360. *
  361. * help - a textual string which describes the purpose of the
  362. * parameter.
  363. *
  364. * ptype - Reference to a PTYPE name. This parameter will be
  365. * validated against the syntax specified for that type.
  366. * The special value of "" indicates the parameter is a boolean flag.
  367. * The verbatim presence of the texual name on the command line
  368. * simply controls the conditional variable expansion for this
  369. * parameter.
  370. *
  371. * [mode] - Parameter mode. It can be "common", "switch", "subcommand", "multi".
  372. *
  373. * [prefix] - defines the prefix for an optional parameter. A prefix
  374. * with this value on the command line will signify the presence
  375. * of an additional argument which will be validated as the
  376. * value of this parameter.
  377. *
  378. * [optional] - Specify whether parameter is optional. The allowed values
  379. * is "true" or "false". It's false by default.
  380. *
  381. * [order] - Used only together with "optional=true" field.
  382. * If order="true" then user can't enter previously declared
  383. * optional parameters after current validated parameter.
  384. * The allowed values is "true" or "false". It's false by default.
  385. *
  386. * [default] - defines a default value for a parameter. Any parameters
  387. * at the end of command line which have default values need
  388. * not explicitly be entered.
  389. *
  390. * [value] - defines the user's value for subcommand. If this option
  391. * is defined the entered parameter will be compared to this
  392. * value instead the "name" field. If this field is defined
  393. * the mode of PARAM will be forced to "subcommand". The
  394. * feature is implemented to support subcommands with the
  395. * same names.
  396. *
  397. * [hidden] - define the visibility of the parameter while ${__line}
  398. * and ${__params} auto variables expanding. The allowed values
  399. * is "true" and "false".
  400. *
  401. * [test] - define the condition (see the description of 'test'
  402. * utility) to process this parameter.
  403. *
  404. * [access] - access rights
  405. *
  406. ********************************************************
  407. -->
  408. <xs:group name="param_group_t">
  409. <xs:choice>
  410. <xs:element ref="PARAM"/>
  411. <xs:element ref="ENTRY"/>
  412. </xs:choice>
  413. </xs:group>
  414. <xs:complexType name="param_t">
  415. <!-- Any order of tags and any number -->
  416. <xs:sequence>
  417. <xs:group ref="param_group_t" minOccurs="0" maxOccurs="unbounded"/>
  418. </xs:sequence>
  419. <xs:attribute name="name" type="xs:string" use="required"/>
  420. <xs:attribute name="help" type="xs:string" use="required"/>
  421. <xs:attribute name="ptype" type="xs:string" use="required"/>
  422. <xs:attribute name="mode" type="entry_mode_t" use="optional" default="sequence"/>
  423. <xs:attribute name="order" type="xs:boolean" use="optional" default="false"/>
  424. <xs:attribute name="value" type="xs:string" use="optional"/>
  425. </xs:complexType>
  426. <!--
  427. *******************************************************
  428. * <COMMAND> is used to define a command within the CLI.
  429. *
  430. * name="<string>" - A textual name for this command. (This may contain
  431. * spaces e.g. "display acl")
  432. *
  433. * help="<string>" - Help for command.
  434. *
  435. * [view] - defines the view which will be transitioned to, on
  436. * successful execution of any <ACTION> tag. By default the
  437. * current view stays in scope.
  438. *
  439. * [viewid] - defined the new value of the ${VIEWID} variable to
  440. * be used if a transition to a new view occurs. By default
  441. * the viewid will retain it's current value.
  442. *
  443. * [access] - defines the user group/level to which execution of this
  444. * command is restricted. By default there is no restriction.
  445. * The exact interpretation of this field is dependant on the
  446. * client of libclish but for example the clish and tclish
  447. * applications map this to the UNIX user groups.
  448. *
  449. * [escape_chars] - defines the characters which will be escaped (e.g. \$) before
  450. * being expanded as a variable. By default the following
  451. * characters will be escaped `|$<>&()#
  452. *
  453. * [args] - defines a parameter name to be used to gather the rest of the
  454. * command line after the formally defined parameters
  455. * (PARAM elements). The formatting of this parameter is a raw
  456. * string containing as many words as there are on the rest of the
  457. * command line.
  458. *
  459. * [args_help] - a textual string which describes the purpose of the 'args'
  460. * parameter. If the "args" attribute is given then this MUST be
  461. * given also.
  462. *
  463. ********************************************************
  464. -->
  465. <xs:complexType name="command_t">
  466. <xs:sequence>
  467. <!-- Any order of PARAM tags and any number -->
  468. <xs:group ref="param_group_t" minOccurs="0" maxOccurs="unbounded"/>
  469. <xs:element ref="ACTION" minOccurs="0" maxOccurs="unbounded"/>
  470. <xs:element ref="COMMAND" minOccurs="0" maxOccurs="unbounded"/>
  471. </xs:sequence>
  472. <xs:attribute name="name" type="xs:string" use="required"/>
  473. <xs:attribute name="help" type="xs:string" use="required"/>
  474. <xs:attribute name="ref" type="xs:string" use="optional"/>
  475. <xs:attribute name="view" type="xs:string" use="optional"/>
  476. <xs:attribute name="viewid" type="xs:string" use="optional"/>
  477. <xs:attribute name="access" type="xs:string" use="optional"/>
  478. <xs:attribute name="args" type="xs:string" use="optional"/>
  479. <xs:attribute name="args_help" type="xs:string" use="optional"/>
  480. <xs:attribute name="escape_chars" type="xs:string" use="optional"/>
  481. </xs:complexType>
  482. </xs:schema>