clish.xsd 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557
  1. <?xml version="1.0"?>
  2. <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://clish.sourceforge.net/XMLSchema" targetNamespace="http://clish.sourceforge.net/XMLSchema">
  3. <!--
  4. ***********************************************************
  5. * Forward declare the main element identifiers
  6. ***********************************************************
  7. -->
  8. <xs:element name="CLISH_MODULE" type="clish_module_t"/>
  9. <xs:element name="VIEW" type="view_t"/>
  10. <xs:element name="COMMAND" type="command_t"/>
  11. <xs:element name="STARTUP" type="startup_t"/>
  12. <xs:element name="ACTION" type="action_t"/>
  13. <xs:element name="OVERVIEW" type="overview_t"/>
  14. <xs:element name="DETAIL" type="detail_t"/>
  15. <xs:element name="PTYPE" type="ptype_t"/>
  16. <xs:element name="PARAM" type="param_t"/>
  17. <xs:element name="NAMESPACE" type="namespace_t"/>
  18. <xs:element name="CONFIG" type="config_t"/>
  19. <xs:element name="VAR" type="var_t"/>
  20. <xs:element name="WATCHDOG" type="wdog_t"/>
  21. <xs:element name="HOTKEY" type="hotkey_t"/>
  22. <xs:element name="PLUGIN" type="plugin_t"/>
  23. <xs:element name="HOOK" type="hook_t"/>
  24. <!--
  25. ***********************************************************
  26. * The common simple types
  27. ***********************************************************
  28. -->
  29. <xs:simpleType name="bool_t">
  30. <xs:restriction base="xs:string">
  31. <xs:enumeration value="true"/>
  32. <xs:enumeration value="false"/>
  33. </xs:restriction>
  34. </xs:simpleType>
  35. <!--
  36. ***********************************************************
  37. * <CLISH_MODULE> is the top level container.
  38. * Any commands which are defined within this tag are global in scope
  39. * i.e. they are visible from all views.
  40. ***********************************************************
  41. -->
  42. <xs:complexType name="clish_module_t">
  43. <xs:sequence>
  44. <xs:element ref="OVERVIEW" minOccurs="0"/>
  45. <xs:element ref="STARTUP" minOccurs="0"/>
  46. <xs:element ref="PTYPE" minOccurs="0" maxOccurs="unbounded"/>
  47. <xs:element ref="COMMAND" minOccurs="0" maxOccurs="unbounded"/>
  48. <xs:element ref="VIEW" minOccurs="0" maxOccurs="unbounded"/>
  49. <xs:element ref="NAMESPACE" minOccurs="0" maxOccurs="unbounded"/>
  50. <xs:element ref="VAR" minOccurs="0" maxOccurs="unbounded"/>
  51. <xs:element ref="WATCHDOG" minOccurs="0" maxOccurs="1"/>
  52. <xs:element ref="HOTKEY" minOccurs="0" maxOccurs="unbounded"/>
  53. <xs:element ref="PLUGIN" minOccurs="0" maxOccurs="unbounded"/>
  54. <xs:element ref="HOOK" minOccurs="0" maxOccurs="unbounded"/>
  55. </xs:sequence>
  56. </xs:complexType>
  57. <!--
  58. ***********************************************************
  59. * Identify some attribute groups
  60. ***********************************************************
  61. -->
  62. <xs:attributeGroup name="menu_item_g">
  63. <xs:attribute name="name" type="xs:string" use="required"/>
  64. <xs:attribute name="help" type="xs:string" use="required"/>
  65. </xs:attributeGroup>
  66. <!--
  67. *******************************************************
  68. * <PTYPE> is used to define the syntax for a parameter type.
  69. *
  70. * name - a textual name for this type. This name can be used to
  71. * reference this type within a <PARAM? ptype attribute.
  72. *
  73. * help - a textual string which describes the syntax of this type.
  74. * When a parameter is filled out incorrectly on the CLI, this
  75. * text will be used to prompt the user to fill out the value
  76. * correctly.
  77. *
  78. * pattern - A regular expression which defines the syntax of the type.
  79. *
  80. * method - The means by which the pattern is interpreted.
  81. *
  82. * "regexp" [default] - A POSIX regular expression.
  83. *
  84. * "integer" - A numeric definition "min..max"
  85. *
  86. * "select" - A list of possible values.
  87. * The syntax of the string is of the form:
  88. * "valueOne(ONE) valueTwo(TWO) valueThree(THREE)"
  89. * where the text before the parethesis defines the syntax
  90. * that the user must use, and the value within the parenthesis
  91. * is the result expanded as a parameter value.
  92. *
  93. * preprocess - An optional directive to process the value entered before
  94. * validating it. This can greatly simplify the regular expressions
  95. * needed to match case insensitive values.
  96. *
  97. * "none" [default] - do nothing
  98. *
  99. * "toupper" - before validation convert to uppercase.
  100. *
  101. * "tolower" - before validation convert to lowercase.
  102. *
  103. ********************************************************
  104. -->
  105. <xs:simpleType name="ptype_method_e">
  106. <xs:restriction base="xs:string">
  107. <xs:enumeration value="regexp"/>
  108. <xs:enumeration value="integer"/>
  109. <xs:enumeration value="unsignedInteger"/>
  110. <xs:enumeration value="select"/>
  111. <xs:enumeration value="choice"/>
  112. <xs:enumeration value="subcommand"/>
  113. </xs:restriction>
  114. </xs:simpleType>
  115. <xs:simpleType name="ptype_preprocess_e">
  116. <xs:restriction base="xs:string">
  117. <xs:enumeration value="none"/>
  118. <xs:enumeration value="toupper"/>
  119. <xs:enumeration value="tolower"/>
  120. </xs:restriction>
  121. </xs:simpleType>
  122. <xs:complexType name="ptype_t">
  123. <xs:attributeGroup ref="menu_item_g"/>
  124. <xs:attribute name="pattern" type="xs:string"/>
  125. <xs:attribute name="method" type="ptype_method_e" use="optional" default="regexp"/>
  126. <xs:attribute name="preprocess" type="ptype_preprocess_e" use="optional" default="none"/>
  127. </xs:complexType>
  128. <!--
  129. *******************************************************
  130. * <VIEW> defines the contents of a specific CLI view.
  131. *
  132. * name - a textual name for the view
  133. *
  134. * prompt - a textual definition of the prompt to be
  135. * used whilst in this view.
  136. * NB. The prompt may contain environment
  137. * or dynamic variables which are expanded
  138. * before display.
  139. *
  140. * [depth] - a depth of nested view (uses for config).
  141. *
  142. * [restore] - restore the depth or view of commands
  143. * contained by this view
  144. ********************************************************
  145. -->
  146. <xs:simpleType name="restore_t">
  147. <xs:restriction base="xs:string">
  148. <xs:enumeration value="none"/>
  149. <xs:enumeration value="depth"/>
  150. <xs:enumeration value="view"/>
  151. </xs:restriction>
  152. </xs:simpleType>
  153. <xs:complexType name="view_t">
  154. <xs:sequence>
  155. <xs:element ref="NAMESPACE" minOccurs="0" maxOccurs="unbounded"/>
  156. <xs:element ref="COMMAND" minOccurs="0" maxOccurs="unbounded"/>
  157. <xs:element ref="HOTKEY" minOccurs="0" maxOccurs="unbounded"/>
  158. </xs:sequence>
  159. <xs:attribute name="name" type="xs:string" use="required"/>
  160. <xs:attribute name="prompt" type="xs:string" use="optional"/>
  161. <xs:attribute name="depth" type="xs:string" use="optional" default="0"/>
  162. <xs:attribute name="restore" type="restore_t" use="optional" default="none"/>
  163. <xs:attribute name="access" type="xs:string" use="optional"/>
  164. </xs:complexType>
  165. <!--
  166. *******************************************************
  167. * <STARTUP> is used to define what happens when the CLI
  168. * is started. Any text held in a <DETAIL> sub-element will
  169. * be used as banner text, then any defined <ACTION> will be
  170. * executed. This action may provide Message Of The Day (MOTD)
  171. * type behaviour.
  172. *
  173. * view - defines the view which will be transitioned to, on
  174. * successful execution of any <ACTION> tag.
  175. *
  176. * [viewid] - defined the new value of the ${VIEWID} variable to
  177. * be used if a transition to a new view occurs.
  178. *
  179. * [default_shebang] - The default shebang for all commands.
  180. *
  181. * [timeout] - The idle timeout. The clish will exit if user
  182. * have not press any key while this timeout.
  183. *
  184. * [lock] - The same as lock for COMMAND tag.
  185. *
  186. * [interrupt] - The same as interrupt for COMMAND tag.
  187. *
  188. * [default_plugin] - Use (or don't use) default plugin.
  189. * It can be true or false.
  190. ********************************************************
  191. -->
  192. <xs:complexType name="startup_t">
  193. <xs:sequence>
  194. <xs:element ref="DETAIL" minOccurs="0"/>
  195. <xs:element ref="ACTION" minOccurs="0"/>
  196. </xs:sequence>
  197. <xs:attribute name="view" type="xs:string" use="required"/>
  198. <xs:attribute name="viewid" type="xs:string" use="optional"/>
  199. <xs:attribute name="default_builtin" type="xs:string" use="optional" default="clish_script@clish"/>
  200. <xs:attribute name="default_shebang" type="xs:string" use="optional"/>
  201. <xs:attribute name="timeout" type="xs:string" use="optional"/>
  202. <xs:attribute name="lock" type="bool_t" use="optional" default="true"/>
  203. <xs:attribute name="interrupt" type="bool_t" use="optional" default="false"/>
  204. <xs:attribute name="default_plugin" type="bool_t" use="optional" default="true"/>
  205. </xs:complexType>
  206. <!--
  207. *******************************************************
  208. * <COMMAND> is used to define a command within the CLI.
  209. *
  210. * name - a textual name for this command. (This may contain
  211. * spaces e.g. "display acl")
  212. *
  213. * help - a textual string which describes the purpose of the
  214. * command.
  215. *
  216. * [view] - defines the view which will be transitioned to, on
  217. * successful execution of any <ACTION> tag. By default the
  218. * current view stays in scope.
  219. *
  220. * [viewid] - defined the new value of the ${VIEWID} variable to
  221. * be used if a transition to a new view occurs. By default
  222. * the viewid will retain it's current value.
  223. *
  224. * [access] - defines the user group/level to which execution of this
  225. * command is restricted. By default there is no restriction.
  226. * The exact interpretation of this field is dependant on the
  227. * client of libclish but for example the clish and tclish
  228. * applications map this to the UNIX user groups.
  229. *
  230. * [escape_chars] - defines the characters which will be escaped (e.g. \$) before
  231. * being expanded as a variable. By default the following
  232. * characters will be escaped `|$<>&()#
  233. *
  234. * [args] - defines a parameter name to be used to gather the rest of the
  235. * command line after the formally defined parameters
  236. * (PARAM elements). The formatting of this parameter is a raw
  237. * string containing as many words as there are on the rest of the
  238. * command line.
  239. *
  240. * [args_help] - a textual string which describes the purpose of the 'args'
  241. * parameter. If the "args" attribute is given then this MUST be
  242. * given also.
  243. *
  244. * [lock] - the boolean field that specify to lock lockfile while
  245. * command execution or not. Default is true.
  246. *
  247. ********************************************************
  248. -->
  249. <xs:complexType name="command_t">
  250. <xs:sequence>
  251. <xs:element ref="DETAIL" minOccurs="0"/>
  252. <xs:element ref="PARAM" minOccurs="0" maxOccurs="unbounded"/>
  253. <xs:element ref="CONFIG" minOccurs="0"/>
  254. <xs:element ref="ACTION" minOccurs="0"/>
  255. </xs:sequence>
  256. <xs:attributeGroup ref="menu_item_g"/>
  257. <xs:attribute name="ref" type="xs:string" use="optional"/>
  258. <xs:attribute name="view" type="xs:string" use="optional"/>
  259. <xs:attribute name="viewid" type="xs:string" use="optional"/>
  260. <xs:attribute name="access" type="xs:string" use="optional"/>
  261. <xs:attribute name="args" type="xs:string" use="optional"/>
  262. <xs:attribute name="args_help" type="xs:string" use="optional"/>
  263. <xs:attribute name="escape_chars" type="xs:string" use="optional"/>
  264. <xs:attribute name="lock" type="bool_t" use="optional" default="true"/>
  265. <xs:attribute name="interrupt" type="bool_t" use="optional" default="false"/>
  266. </xs:complexType>
  267. <!--
  268. *******************************************************
  269. * <PARAM> This tag is used to define a parameter for a command.
  270. *
  271. * name - a textual name for this parameter.
  272. *
  273. * help - a textual string which describes the purpose of the
  274. * parameter.
  275. *
  276. * ptype - Reference to a PTYPE name. This parameter will be
  277. * validated against the syntax specified for that type.
  278. * The special value of "" indicates the parameter is a boolean flag.
  279. * The verbatim presence of the texual name on the command line
  280. * simply controls the conditional variable expansion for this
  281. * parameter.
  282. *
  283. * [mode] - Parameter mode. It can be "common", "switch" or
  284. * "subcommand".
  285. *
  286. * [prefix] - defines the prefix for an optional parameter. A prefix
  287. * with this value on the command line will signify the presence
  288. * of an additional argument which will be validated as the
  289. * value of this parameter.
  290. *
  291. * [optional]- Specify whether parameter is optional. The allowed values
  292. * is "true" or "false". It's false by default.
  293. *
  294. * [order] - Used only together with "optional=true" field.
  295. * If order="true" then user can't enter previously declared
  296. * optional parameters after current validated parameter.
  297. * The allowed values is "true" or "false". It's false by default.
  298. *
  299. * [default] - defines a default value for a parameter. Any parameters
  300. * at the end of command line which have default values need
  301. * not explicitly be entered.
  302. *
  303. * [value] - defines the user's value for subcommand. If this option
  304. * is defined the entered parameter will be compared to this
  305. * value instead the "name" field. If this field is defined
  306. * the mode of PARAM will be forced to "subcommand". The
  307. * feature is implemented to support subcommands with the
  308. * same names.
  309. *
  310. * [hidden] - define the visibility of the parameter while ${__line}
  311. * and ${__params} auto variables expanding. The allowed values
  312. * is "true" and "false".
  313. *
  314. * [test] - define the condition (see the description of 'test'
  315. * utility) to process this parameter.
  316. ********************************************************
  317. -->
  318. <xs:simpleType name="param_mode_t">
  319. <xs:restriction base="xs:string">
  320. <xs:enumeration value="common"/>
  321. <xs:enumeration value="switch"/>
  322. <xs:enumeration value="subcommand"/>
  323. </xs:restriction>
  324. </xs:simpleType>
  325. <xs:complexType name="param_t">
  326. <xs:sequence>
  327. <xs:element ref="PARAM" minOccurs="0" maxOccurs="unbounded"/>
  328. </xs:sequence>
  329. <xs:attributeGroup ref="menu_item_g"/>
  330. <xs:attribute name="ptype" type="xs:string" use="required"/>
  331. <xs:attribute name="default" type="xs:string" use="optional"/>
  332. <xs:attribute name="prefix" type="xs:string" use="optional"/>
  333. <xs:attribute name="mode" type="param_mode_t" use="optional" default="common"/>
  334. <xs:attribute name="optional" type="bool_t" use="optional" default="false"/>
  335. <xs:attribute name="order" type="bool_t" use="optional" default="false"/>
  336. <xs:attribute name="value" type="xs:string" use="optional"/>
  337. <xs:attribute name="hidden" type="bool_t" use="optional" default="false"/>
  338. <xs:attribute name="test" type="xs:string" use="optional"/>
  339. <xs:attribute name="completion" type="xs:string" use="optional"/>
  340. </xs:complexType>
  341. <!--
  342. ********************************************************
  343. * <ACTION> specifies the action to be taken for
  344. * a command.
  345. *
  346. * The textual contents of the tag are variable expanded
  347. * (environment, dynamic and parameter) the the resulting
  348. * text is interpreted by the client's script interpreter.
  349. *
  350. * In addition the optional 'builtin' attribute can specify
  351. * the name of an internal command which will be invoked
  352. * instead of the client's script handler.
  353. *
  354. * NB. for security reasons any special shell characters
  355. * (e.g. $|<>`) are escaped before evaluation.
  356. *
  357. * [builtin] - specify the name of an internally registered
  358. * function. The content of the ACTION tag is
  359. * taken as the arguments to this builtin function.
  360. *
  361. * [shebang] - specify the programm to execute the action
  362. * script.
  363. ********************************************************
  364. -->
  365. <xs:complexType name="action_t">
  366. <xs:simpleContent>
  367. <xs:extension base="xs:string">
  368. <xs:attribute name="builtin" type="xs:string" use="optional"/>
  369. <xs:attribute name="shebang" type="xs:string" use="optional"/>
  370. </xs:extension>
  371. </xs:simpleContent>
  372. </xs:complexType>
  373. <!--
  374. ********************************************************
  375. * <OVERVIEW> specifies a textual description of the shell.
  376. *
  377. * This should provide instructions about key bindings and
  378. * escape sequences which can be used in the CLI.
  379. *
  380. ********************************************************
  381. -->
  382. <xs:simpleType name="overview_t">
  383. <xs:restriction base="xs:string">
  384. <xs:whiteSpace value="preserve"/>
  385. </xs:restriction>
  386. </xs:simpleType>
  387. <!--
  388. ********************************************************
  389. * <DETAIL> specifies a textual description.
  390. *
  391. * This may be used within the scope of a <COMMAND>
  392. * element, in which case it would typically contain
  393. * detailed usage instructions including examples.
  394. *
  395. * This may also be used within the scope of a <STARTUP>
  396. * element, in which case the text is used as the banner
  397. * details which are displayed on shell startup. This is
  398. * shown before any specified <ACTION> is executed.
  399. *
  400. * This text may also be used in the production of user manuals.
  401. ********************************************************
  402. -->
  403. <xs:simpleType name="detail_t">
  404. <xs:restriction base="xs:string">
  405. <xs:whiteSpace value="preserve"/>
  406. </xs:restriction>
  407. </xs:simpleType>
  408. <!--
  409. *******************************************************
  410. * <NAMESPACE> import commands from specific view to current view.
  411. *
  412. * ref - the view to import commands from
  413. *
  414. * [prefix] - the prefix for imported commands
  415. *
  416. * [prefix_help] - the help for namespace prefix
  417. *
  418. * [help] - a boolean flag to use imported
  419. * commands while help
  420. *
  421. * [completion] - a boolean flag to use imported
  422. * commands while completion
  423. *
  424. * [context_help] - a boolean flag to use imported
  425. * commands while context help
  426. *
  427. * [inherit] - a boolean flag to inherit nested
  428. * namespace commands recursively
  429. ********************************************************
  430. -->
  431. <xs:complexType name="namespace_t">
  432. <xs:attribute name="ref" type="xs:string" use="required"/>
  433. <xs:attribute name="prefix" type="xs:string" use="optional"/>
  434. <xs:attribute name="prefix_help" type="xs:string" use="optional"/>
  435. <xs:attribute name="help" type="bool_t" use="optional" default="false"/>
  436. <xs:attribute name="completion" type="bool_t" use="optional" default="true"/>
  437. <xs:attribute name="context_help" type="bool_t" use="optional" default="false"/>
  438. <xs:attribute name="inherit" type="bool_t" use="optional" default="true"/>
  439. <xs:attribute name="access" type="xs:string" use="optional"/>
  440. </xs:complexType>
  441. <!--
  442. *******************************************************
  443. * <CONFIG> Specify the config operation.
  444. *
  445. * operation - config operation to perform
  446. *
  447. ********************************************************
  448. -->
  449. <xs:simpleType name="operation_t">
  450. <xs:restriction base="xs:string">
  451. <xs:enumeration value="none"/>
  452. <xs:enumeration value="set"/>
  453. <xs:enumeration value="unset"/>
  454. <xs:enumeration value="dump"/>
  455. </xs:restriction>
  456. </xs:simpleType>
  457. <xs:complexType name="config_t">
  458. <xs:attribute name="operation" type="operation_t" use="optional" default="set"/>
  459. <xs:attribute name="priority" type="xs:string" use="optional" default="0x7f00"/>
  460. <xs:attribute name="pattern" type="xs:string" use="optional" default="^${__cmd}"/>
  461. <xs:attribute name="file" type="xs:string" use="optional" default="startup-config"/>
  462. <xs:attribute name="splitter" type="bool_t" use="optional" default="true"/>
  463. <xs:attribute name="sequence" type="xs:string" use="optional" default="0"/>
  464. <xs:attribute name="unique" type="bool_t" use="optional" default="true"/>
  465. <xs:attribute name="depth" type="xs:string" use="optional"/>
  466. </xs:complexType>
  467. <!--
  468. *******************************************************
  469. * <VAR> Specify the variable.
  470. *
  471. *
  472. *
  473. ********************************************************
  474. -->
  475. <xs:complexType name="var_t">
  476. <xs:sequence>
  477. <xs:element ref="ACTION" minOccurs="0"/>
  478. </xs:sequence>
  479. <xs:attribute name="name" type="xs:string" use="required"/>
  480. <xs:attribute name="help" type="xs:string" use="optional"/>
  481. <xs:attribute name="value" type="xs:string" use="optional"/>
  482. <xs:attribute name="dynamic" type="bool_t" use="optional" default="false"/>
  483. </xs:complexType>
  484. <!--
  485. *******************************************************
  486. * <WATCHDOG> is used to recover system after errors.
  487. *
  488. ********************************************************
  489. -->
  490. <xs:complexType name="wdog_t">
  491. <xs:sequence>
  492. <xs:element ref="ACTION" minOccurs="1"/>
  493. </xs:sequence>
  494. </xs:complexType>
  495. <!--
  496. *******************************************************
  497. * <HOTKEY> is used to define hotkey actions
  498. *
  499. ********************************************************
  500. -->
  501. <xs:complexType name="hotkey_t">
  502. <xs:attribute name="key" type="xs:string" use="required"/>
  503. <xs:attribute name="cmd" type="xs:string" use="required"/>
  504. </xs:complexType>
  505. <!--
  506. *******************************************************
  507. * <PLUGIN> is used to dynamically load plugins
  508. *
  509. ********************************************************
  510. -->
  511. <xs:complexType name="plugin_t">
  512. <xs:attribute name="file" type="xs:string" use="required"/>
  513. <xs:attribute name="name" type="xs:string" use="optional"/>
  514. </xs:complexType>
  515. <!--
  516. *******************************************************
  517. * <HOOK> is used to redefine internal hooks
  518. *
  519. * name - The name of internal hook (init, fini, access, config, log).
  520. *
  521. * [builtin] - specify the name of an internally registered
  522. * function.
  523. *
  524. ********************************************************
  525. -->
  526. <xs:simpleType name="hook_list_e">
  527. <xs:restriction base="xs:string">
  528. <xs:enumeration value="init"/>
  529. <xs:enumeration value="fini"/>
  530. <xs:enumeration value="access"/>
  531. <xs:enumeration value="config"/>
  532. <xs:enumeration value="log"/>
  533. </xs:restriction>
  534. </xs:simpleType>
  535. <xs:complexType name="hook_t">
  536. <xs:attribute name="name" type="hook_list_e"/>
  537. <xs:attribute name="builtin" type="xs:string" use="optional"/>
  538. </xs:complexType>
  539. </xs:schema>