klish.xsd 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550
  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="VIEW" type="view_t"/>
  20. <xs:element name="COMMAND" type="command_t"/>
  21. <xs:element name="FILTER" type="command_t"/>
  22. <xs:element name="STARTUP" type="startup_t"/>
  23. <xs:element name="ACTION" type="action_t"/>
  24. <xs:element name="OVERVIEW" type="overview_t"/>
  25. <xs:element name="DETAIL" type="detail_t"/>
  26. <xs:element name="PTYPE" type="ptype_t"/>
  27. <xs:element name="PARAM" type="param_t"/>
  28. <xs:element name="SWITCH" type="param_t"/> <!-- PARAM alias -->
  29. <xs:element name="SUBCOMMAND" type="param_t"/> <!-- PARAM alias -->
  30. <xs:element name="MULTI" type="param_t"/> <!-- PARAM alias -->
  31. <xs:element name="NAMESPACE" type="namespace_t"/>
  32. <xs:element name="VAR" type="var_t"/>
  33. <xs:element name="WATCHDOG" type="wdog_t"/>
  34. <xs:element name="HOTKEY" type="hotkey_t"/>
  35. <xs:element name="PLUGIN" type="plugin_t"/>
  36. <xs:element name="HOOK" type="hook_t"/>
  37. <xs:complexType name="klish_t">
  38. <xs:annotation>
  39. <xs:documentation xml:lang="en">
  40. 'KLISH' is the top level container. Any object (command,
  41. type, var) which are defined within this tag are global
  42. in scope i.e. it is visible from all 'VIEW's.
  43. </xs:documentation>
  44. <xs:documentation xml:lang="ru">
  45. Тег 'KLISH' - контейнер верхнего уровня. Все остальные
  46. теги должны быть вложенными. Любой объект (команда,
  47. тип, переменная т.д.), заданный внутри этого тега,
  48. считается глобальным, т.е. видимым их любых 'VIEW".
  49. </xs:documentation>
  50. </xs:annotation>
  51. <xs:sequence>
  52. <xs:element ref="PLUGIN" minOccurs="0" maxOccurs="unbounded"/>
  53. <xs:element ref="HOOK" minOccurs="0" maxOccurs="unbounded"/>
  54. <xs:element ref="HOTKEY" minOccurs="0" maxOccurs="unbounded"/>
  55. <xs:element ref="WATCHDOG" minOccurs="0" maxOccurs="1"/>
  56. <xs:element ref="PTYPE" minOccurs="0" maxOccurs="unbounded"/>
  57. <xs:element ref="OVERVIEW" minOccurs="0"/>
  58. <xs:element ref="STARTUP" minOccurs="0"/>
  59. <xs:element ref="VAR" minOccurs="0" maxOccurs="unbounded"/>
  60. <xs:element ref="VIEW" minOccurs="0" maxOccurs="unbounded"/>
  61. </xs:sequence>
  62. </xs:complexType>
  63. <!--
  64. *******************************************************
  65. * <PTYPE> is used to define the syntax for a parameter type.
  66. *
  67. * name="<string>" - A textual name for this type. This name can be used to
  68. * reference this type within a PARAM's ptype attribute.
  69. *
  70. * help="<string>" - Help string.
  71. *
  72. ********************************************************
  73. -->
  74. <xs:complexType name="ptype_t">
  75. <xs:sequence>
  76. <xs:element ref="ACTION" minOccurs="0" maxOccurs="unbounded"/>
  77. </xs:sequence>
  78. <xs:attribute name="name" type="xs:string" use="required"/>
  79. <xs:attribute name="help" type="xs:string" use="required"/>
  80. </xs:complexType>
  81. <!--
  82. *******************************************************
  83. * <VIEW> defines the contents of a specific CLI view.
  84. *
  85. * name - a textual name for the view
  86. *
  87. * prompt - a textual definition of the prompt to be
  88. * used whilst in this view.
  89. * NB. The prompt may contain environment
  90. * or dynamic variables which are expanded
  91. * before display.
  92. *
  93. * [depth] - a depth of nested view (uses for config).
  94. *
  95. * [restore] - restore the depth or view of commands
  96. * contained by this view
  97. *
  98. * [access] - access rights
  99. *
  100. ********************************************************
  101. -->
  102. <xs:simpleType name="restore_t">
  103. <xs:restriction base="xs:string">
  104. <xs:enumeration value="none"/>
  105. <xs:enumeration value="depth"/>
  106. <xs:enumeration value="view"/>
  107. </xs:restriction>
  108. </xs:simpleType>
  109. <xs:complexType name="view_t">
  110. <xs:sequence>
  111. <xs:element ref="NAMESPACE" minOccurs="0" maxOccurs="unbounded"/>
  112. <xs:element ref="COMMAND" minOccurs="0" maxOccurs="unbounded"/>
  113. <xs:element ref="HOTKEY" minOccurs="0" maxOccurs="unbounded"/>
  114. </xs:sequence>
  115. <xs:attribute name="name" type="xs:string" use="required"/>
  116. <xs:attribute name="prompt" type="xs:string" use="optional"/>
  117. <xs:attribute name="depth" type="xs:string" use="optional" default="0"/>
  118. <xs:attribute name="restore" type="restore_t" use="optional" default="none"/>
  119. <xs:attribute name="access" type="xs:string" use="optional"/>
  120. </xs:complexType>
  121. <!--
  122. *******************************************************
  123. * <STARTUP> is used to define what happens when the CLI
  124. * is started. Any text held in a <DETAIL> sub-element will
  125. * be used as banner text, then any defined <ACTION> will be
  126. * executed. This action may provide Message Of The Day (MOTD)
  127. * type behaviour.
  128. *
  129. * view - defines the view which will be transitioned to, on
  130. * successful execution of any <ACTION> tag.
  131. *
  132. * [viewid] - defined the new value of the ${VIEWID} variable to
  133. * be used if a transition to a new view occurs.
  134. *
  135. * [default_shebang] - The default shebang for all commands.
  136. *
  137. * [timeout] - The idle timeout. The clish will exit if user
  138. * have not press any key while this timeout.
  139. *
  140. * [lock] - The same as lock for COMMAND tag.
  141. *
  142. * [interrupt] - The same as interrupt for COMMAND tag.
  143. *
  144. * [default_plugin] - Use (or don't use) default plugin.
  145. * It can be true or false.
  146. ********************************************************
  147. -->
  148. <xs:complexType name="startup_t">
  149. <xs:sequence>
  150. <xs:element ref="DETAIL" minOccurs="0"/>
  151. <xs:element ref="ACTION" minOccurs="0" maxOccurs="unbounded"/>
  152. </xs:sequence>
  153. <xs:attribute name="view" type="xs:string" use="required"/>
  154. <xs:attribute name="viewid" type="xs:string" use="optional"/>
  155. <xs:attribute name="default_shebang" type="xs:string" use="optional"/>
  156. <xs:attribute name="timeout" type="xs:string" use="optional"/>
  157. <xs:attribute name="default_plugin" type="xs:boolean" use="optional" default="true"/>
  158. </xs:complexType>
  159. <!--
  160. *******************************************************
  161. * <PARAM> This tag is used to define a parameter for a command.
  162. *
  163. * name - a textual name for this parameter.
  164. *
  165. * help - a textual string which describes the purpose of the
  166. * parameter.
  167. *
  168. * ptype - Reference to a PTYPE name. This parameter will be
  169. * validated against the syntax specified for that type.
  170. * The special value of "" indicates the parameter is a boolean flag.
  171. * The verbatim presence of the texual name on the command line
  172. * simply controls the conditional variable expansion for this
  173. * parameter.
  174. *
  175. * [mode] - Parameter mode. It can be "common", "switch", "subcommand", "multi".
  176. *
  177. * [prefix] - defines the prefix for an optional parameter. A prefix
  178. * with this value on the command line will signify the presence
  179. * of an additional argument which will be validated as the
  180. * value of this parameter.
  181. *
  182. * [optional] - Specify whether parameter is optional. The allowed values
  183. * is "true" or "false". It's false by default.
  184. *
  185. * [order] - Used only together with "optional=true" field.
  186. * If order="true" then user can't enter previously declared
  187. * optional parameters after current validated parameter.
  188. * The allowed values is "true" or "false". It's false by default.
  189. *
  190. * [default] - defines a default value for a parameter. Any parameters
  191. * at the end of command line which have default values need
  192. * not explicitly be entered.
  193. *
  194. * [value] - defines the user's value for subcommand. If this option
  195. * is defined the entered parameter will be compared to this
  196. * value instead the "name" field. If this field is defined
  197. * the mode of PARAM will be forced to "subcommand". The
  198. * feature is implemented to support subcommands with the
  199. * same names.
  200. *
  201. * [hidden] - define the visibility of the parameter while ${__line}
  202. * and ${__params} auto variables expanding. The allowed values
  203. * is "true" and "false".
  204. *
  205. * [test] - define the condition (see the description of 'test'
  206. * utility) to process this parameter.
  207. *
  208. * [access] - access rights
  209. *
  210. ********************************************************
  211. -->
  212. <xs:simpleType name="param_mode_t">
  213. <xs:restriction base="xs:string">
  214. <xs:enumeration value="common"/>
  215. <xs:enumeration value="switch"/>
  216. <xs:enumeration value="subcommand"/>
  217. <xs:enumeration value="multi"/>
  218. </xs:restriction>
  219. </xs:simpleType>
  220. <xs:group name="param_group_t">
  221. <xs:choice>
  222. <xs:element ref="PARAM"/>
  223. <xs:element ref="SWITCH"/>
  224. <xs:element ref="SUBCOMMAND"/>
  225. <xs:element ref="MULTI"/>
  226. </xs:choice>
  227. </xs:group>
  228. <xs:complexType name="param_t">
  229. <!-- Any order of tags and any number -->
  230. <xs:sequence>
  231. <xs:group ref="param_group_t" minOccurs="0" maxOccurs="unbounded"/>
  232. </xs:sequence>
  233. <xs:attribute name="name" type="xs:string" use="required"/>
  234. <xs:attribute name="help" type="xs:string" use="required"/>
  235. <xs:attribute name="ptype" type="xs:string" use="required"/>
  236. <xs:attribute name="default" type="xs:string" use="optional"/>
  237. <xs:attribute name="prefix" type="xs:string" use="optional"/>
  238. <xs:attribute name="mode" type="param_mode_t" use="optional" default="common"/>
  239. <xs:attribute name="optional" type="xs:boolean" use="optional" default="false"/>
  240. <xs:attribute name="order" type="xs:boolean" use="optional" default="false"/>
  241. <xs:attribute name="value" type="xs:string" use="optional"/>
  242. <xs:attribute name="hidden" type="xs:boolean" use="optional" default="false"/>
  243. <xs:attribute name="test" type="xs:string" use="optional"/>
  244. <xs:attribute name="completion" type="xs:string" use="optional"/>
  245. <xs:attribute name="access" type="xs:string" use="optional"/>
  246. </xs:complexType>
  247. <!--
  248. ********************************************************
  249. * <ACTION> specifies the action to be taken for
  250. * a command.
  251. *
  252. * In addition the optional 'sym' attribute can specify
  253. * the name of an internal command which will be invoked
  254. * to handle script.
  255. *
  256. * [sym="<symbol>"] - specify the name of an internally registered
  257. * function. The content of the ACTION tag is
  258. * taken as the arguments to this builtin function.
  259. *
  260. * [lock="<name>"] - Named lock. It will use special lockfile while
  261. * action execution.
  262. *
  263. * [interrupt="true/false"] - The boolean field that specify that action can be
  264. * be interrupted by Ctrl^C. Default is false. Ignored for non-interactive
  265. * actions.
  266. *
  267. * [interactive="true/false"] - Is action interactive.
  268. *
  269. * [exec_on="fail/success/always"] - ACTION's execution depends on
  270. * return code of previous elements of ACTION chain. If the
  271. * condition is not met then ACTION will not be executed. The "always"
  272. * value means that ACTION will be always executed and chain return
  273. * code will be ignored. Default is "success".
  274. *
  275. * [update_retcode="true/false"] - The chain return value can be updated
  276. * by current ACTION's return code or ACTION's return code can be ignored.
  277. * Default is "true".
  278. *
  279. ********************************************************
  280. -->
  281. <xs:simpleType name="action_cond_t">
  282. <xs:restriction base="xs:string">
  283. <xs:enumeration value="fail"/>
  284. <xs:enumeration value="success"/>
  285. <xs:enumeration value="always"/>
  286. </xs:restriction>
  287. </xs:simpleType>
  288. <xs:complexType name="action_t">
  289. <xs:simpleContent>
  290. <xs:extension base="xs:string">
  291. <xs:attribute name="sym" type="xs:string" use="optional"/>
  292. <xs:attribute name="lock" type="xs:string" use="optional"/>
  293. <xs:attribute name="interrupt" type="xs:boolean" use="optional" default="false"/>
  294. <xs:attribute name="interactive" type="xs:boolean" use="optional" default="false"/>
  295. <xs:attribute name="exec_on" type="action_cond_t" use="optional" default="success"/>
  296. <xs:attribute name="update_retcode" type="xs:boolean" use="optional" default="true"/>
  297. </xs:extension>
  298. </xs:simpleContent>
  299. </xs:complexType>
  300. <!--
  301. *******************************************************
  302. * <COMMAND> is used to define a command within the CLI.
  303. *
  304. * name="<string>" - A textual name for this command. (This may contain
  305. * spaces e.g. "display acl")
  306. *
  307. * help="<string>" - Help for command.
  308. *
  309. * [view] - defines the view which will be transitioned to, on
  310. * successful execution of any <ACTION> tag. By default the
  311. * current view stays in scope.
  312. *
  313. * [viewid] - defined the new value of the ${VIEWID} variable to
  314. * be used if a transition to a new view occurs. By default
  315. * the viewid will retain it's current value.
  316. *
  317. * [access] - defines the user group/level to which execution of this
  318. * command is restricted. By default there is no restriction.
  319. * The exact interpretation of this field is dependant on the
  320. * client of libclish but for example the clish and tclish
  321. * applications map this to the UNIX user groups.
  322. *
  323. * [escape_chars] - defines the characters which will be escaped (e.g. \$) before
  324. * being expanded as a variable. By default the following
  325. * characters will be escaped `|$<>&()#
  326. *
  327. * [args] - defines a parameter name to be used to gather the rest of the
  328. * command line after the formally defined parameters
  329. * (PARAM elements). The formatting of this parameter is a raw
  330. * string containing as many words as there are on the rest of the
  331. * command line.
  332. *
  333. * [args_help] - a textual string which describes the purpose of the 'args'
  334. * parameter. If the "args" attribute is given then this MUST be
  335. * given also.
  336. *
  337. ********************************************************
  338. -->
  339. <xs:complexType name="command_t">
  340. <xs:sequence>
  341. <xs:element ref="DETAIL" minOccurs="0"/>
  342. <!-- Any order of PARAM tags and any number -->
  343. <xs:group ref="param_group_t" minOccurs="0" maxOccurs="unbounded"/>
  344. <xs:element ref="ACTION" minOccurs="0" maxOccurs="unbounded"/>
  345. </xs:sequence>
  346. <xs:attribute name="name" type="xs:string" use="required"/>
  347. <xs:attribute name="help" type="xs:string" use="required"/>
  348. <xs:attribute name="ref" type="xs:string" use="optional"/>
  349. <xs:attribute name="view" type="xs:string" use="optional"/>
  350. <xs:attribute name="viewid" type="xs:string" use="optional"/>
  351. <xs:attribute name="access" type="xs:string" use="optional"/>
  352. <xs:attribute name="args" type="xs:string" use="optional"/>
  353. <xs:attribute name="args_help" type="xs:string" use="optional"/>
  354. <xs:attribute name="escape_chars" type="xs:string" use="optional"/>
  355. </xs:complexType>
  356. <!--
  357. ********************************************************
  358. * <OVERVIEW> specifies a textual description of the shell.
  359. *
  360. * This should provide instructions about key bindings and
  361. * escape sequences which can be used in the CLI.
  362. *
  363. ********************************************************
  364. -->
  365. <xs:simpleType name="overview_t">
  366. <xs:restriction base="xs:string">
  367. <xs:whiteSpace value="preserve"/>
  368. </xs:restriction>
  369. </xs:simpleType>
  370. <!--
  371. ********************************************************
  372. * <DETAIL> specifies a textual description.
  373. *
  374. * This may be used within the scope of a <COMMAND>
  375. * element, in which case it would typically contain
  376. * detailed usage instructions including examples.
  377. *
  378. * This may also be used within the scope of a <STARTUP>
  379. * element, in which case the text is used as the banner
  380. * details which are displayed on shell startup. This is
  381. * shown before any specified <ACTION> is executed.
  382. *
  383. * This text may also be used in the production of user manuals.
  384. ********************************************************
  385. -->
  386. <xs:simpleType name="detail_t">
  387. <xs:restriction base="xs:string">
  388. <xs:whiteSpace value="preserve"/>
  389. </xs:restriction>
  390. </xs:simpleType>
  391. <!--
  392. *******************************************************
  393. * <NAMESPACE> import commands from specific view to current view.
  394. *
  395. * ref - the view to import commands from
  396. *
  397. * [prefix] - the prefix for imported commands
  398. *
  399. * [prefix_help] - the help for namespace prefix
  400. *
  401. * [help] - a boolean flag to use imported
  402. * commands while help
  403. *
  404. * [completion] - a boolean flag to use imported
  405. * commands while completion
  406. *
  407. * [context_help] - a boolean flag to use imported
  408. * commands while context help
  409. *
  410. * [inherit] - a boolean flag to inherit nested
  411. * namespace commands recursively
  412. *
  413. * [access] - access rights
  414. *
  415. ********************************************************
  416. -->
  417. <xs:complexType name="namespace_t">
  418. <xs:attribute name="ref" type="xs:string" use="required"/>
  419. <xs:attribute name="prefix" type="xs:string" use="optional"/>
  420. <xs:attribute name="prefix_help" type="xs:string" use="optional"/>
  421. <xs:attribute name="help" type="xs:boolean" use="optional" default="false"/>
  422. <xs:attribute name="completion" type="xs:boolean" use="optional" default="true"/>
  423. <xs:attribute name="context_help" type="xs:boolean" use="optional" default="false"/>
  424. <xs:attribute name="inherit" type="xs:boolean" use="optional" default="true"/>
  425. <xs:attribute name="access" type="xs:string" use="optional"/>
  426. </xs:complexType>
  427. <!--
  428. *******************************************************
  429. * <VAR> Specify the variable.
  430. *
  431. *
  432. *
  433. ********************************************************
  434. -->
  435. <xs:complexType name="var_t">
  436. <xs:sequence>
  437. <xs:element ref="ACTION" minOccurs="0" maxOccurs="unbounded"/>
  438. </xs:sequence>
  439. <xs:attribute name="name" type="xs:string" use="required"/>
  440. <xs:attribute name="help" type="xs:string" use="optional"/>
  441. <xs:attribute name="value" type="xs:string" use="optional"/>
  442. <xs:attribute name="dynamic" type="xs:boolean" use="optional" default="false"/>
  443. </xs:complexType>
  444. <!--
  445. *******************************************************
  446. * <WATCHDOG> is used to recover system after errors.
  447. *
  448. ********************************************************
  449. -->
  450. <xs:complexType name="wdog_t">
  451. <xs:sequence>
  452. <xs:element ref="ACTION" minOccurs="1" maxOccurs="unbounded"/>
  453. </xs:sequence>
  454. </xs:complexType>
  455. <!--
  456. *******************************************************
  457. * <HOTKEY> is used to define hotkey actions
  458. *
  459. ********************************************************
  460. -->
  461. <xs:complexType name="hotkey_t">
  462. <xs:attribute name="key" type="xs:string" use="required"/>
  463. <xs:attribute name="cmd" type="xs:string" use="required"/>
  464. </xs:complexType>
  465. <!--
  466. *******************************************************
  467. * <PLUGIN> is used to dynamically load plugins.
  468. * Plugin contains symbols that can be used for ACTIONs.
  469. *
  470. * name - Plugin name. If "file" attribute is not specified then plugin's
  471. * filename is autogenerated as "klish-plugin-<name>.so".
  472. * [id] - Internal plugin name. Can be the same as "name".
  473. * [file] - File name if standard autogenerated filename (using "name" field)
  474. * is not appropriate.
  475. ********************************************************
  476. -->
  477. <xs:complexType name="plugin_t">
  478. <xs:simpleContent>
  479. <xs:extension base="xs:string">
  480. <xs:attribute name="name" type="xs:string" use="required"/>
  481. <xs:attribute name="id" type="xs:string" use="optional"/>
  482. <xs:attribute name="file" type="xs:string" use="optional"/>
  483. </xs:extension>
  484. </xs:simpleContent>
  485. </xs:complexType>
  486. <!--
  487. *******************************************************
  488. * <HOOK> is used to redefine internal hooks
  489. *
  490. * name - The name of internal hook (init, fini, access, log).
  491. *
  492. * [builtin] - specify the name of an internally registered
  493. * function.
  494. *
  495. ********************************************************
  496. -->
  497. <xs:simpleType name="hook_list_e">
  498. <xs:restriction base="xs:string">
  499. <xs:enumeration value="init"/>
  500. <xs:enumeration value="fini"/>
  501. <xs:enumeration value="access"/>
  502. <xs:enumeration value="log"/>
  503. </xs:restriction>
  504. </xs:simpleType>
  505. <xs:complexType name="hook_t">
  506. <xs:attribute name="name" type="hook_list_e"/>
  507. <xs:attribute name="builtin" type="xs:string" use="optional"/>
  508. </xs:complexType>
  509. </xs:schema>