klish.xsd 20 KB

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