klish.xsd 19 KB

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