clish.xsd 22 KB

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