Browse Source

xsd: Some refactoring

Serj Kalichev 1 year ago
parent
commit
2e2df54ac6
1 changed files with 98 additions and 119 deletions
  1. 98 119
      klish.xsd

+ 98 - 119
klish.xsd

@@ -40,7 +40,7 @@
 
 <!--
 *******************************************************
-* <KLISH>
+* <KLISH> is a top level container.
 ********************************************************
 -->
 	<xs:group name="klish_group_t">
@@ -77,9 +77,15 @@
 *
 * name - Plugin name. If "file" attribute is not specified then plugin's
 *	filename is autogenerated as "kplugin-<name>.so".
+*
 * [id] - Internal plugin name for references. Can be the same as "name".
+*
 * [file] - File name to use if standard autogenerated filename (using "name"
 *	field) is not appropriate.
+*
+* The content of PLUGIN tag can be used as a config file for this plugin.
+* Parsing of this content must be implemented within plugin's init.
+*
 ********************************************************
 -->
 	<xs:complexType name="plugin_t">
@@ -101,6 +107,97 @@
 		</xs:simpleContent>
 	</xs:complexType>
 
+
+<!--
+*******************************************************
+* <HOTKEY> is used to define hotkey actions
+*
+* key - Hot-key
+*
+* cmd - Text string defines command to execute on pressing hot-key. It's like
+*	a common user CLI input. This string will be interpreted by CLI engine.
+*
+********************************************************
+-->
+	<xs:complexType name="hotkey_t">
+		<xs:attribute name="key" type="xs:string" use="required"/>
+		<xs:attribute name="cmd" type="xs:string" use="required"/>
+	</xs:complexType>
+
+
+<!--
+********************************************************
+* <ACTION> specifies the action to be taken for
+* a command.
+*
+* In addition the optional 'sym' attribute can specify
+* the name of an internal command which will be invoked
+* to handle script.
+*
+* [sym="<symbol>"] - specify the name of an internally registered
+*	function (symbol). The content of the ACTION tag is
+*	taken as the arguments to this function. Plugins can define
+*	these symbols. The "<symbol>" can be defined as "sym@plugin" i.e.
+*	parental plugin can be defined explicitly.
+*
+* [lock="<name>"] - Named lock. It will use special lockfile while
+*	action execution.
+*
+* [interrupt="true/false"] - The boolean field that specify that action can be
+*	be interrupted by Ctrl^C. Default is false. Ignored for non-interactive
+*	actions.
+*
+* [interactive="true/false"] - Is action interactive.
+*
+* [exec_on="fail/success/always/never"] - ACTION's execution depends on
+*	return code of previous elements of ACTION chain. If the
+*	condition is not met then ACTION will not be executed. The "always"
+*	value means that ACTION will be always executed and chain return
+*	code will be ignored. Default is "success".
+*
+* [update_retcode="true/false"] - The chain return value can be updated
+*	by current ACTION's return code or ACTION's return code can be ignored.
+*	Default is "true".
+*
+* [permanent="true/false"] - The klish can be invoked with dry-run option. In
+*	this case all ACTIONs will be not actually executed but will always
+*	return success. But some actions like navigation is necessary to be
+*	executed in any case. Permanent flag will inform engine to always
+*	execute ACTION.
+*
+* [sync="true/false"] - Common behaviour is to fork() process before ACTION
+*	execution. But ACTION may be executed in-place (without fork()) if sync
+*	flag is set to true. It's not recommended to use sync ACTIONs widely.
+*	It's usefull for small fast functions only.
+*
+********************************************************
+-->
+
+	<xs:simpleType name="action_cond_t">
+		<xs:restriction base="xs:string">
+			<xs:enumeration value="fail"/>
+			<xs:enumeration value="success"/>
+			<xs:enumeration value="always"/>
+			<xs:enumeration value="never"/>
+		</xs:restriction>
+	</xs:simpleType>
+
+	<xs:complexType name="action_t">
+		<xs:simpleContent>
+			<xs:extension base="xs:string">
+				<xs:attribute name="sym" type="xs:string" use="optional"/>
+				<xs:attribute name="lock" type="xs:string" use="optional"/>
+				<xs:attribute name="interrupt" type="xs:boolean" use="optional" default="false"/>
+				<xs:attribute name="interactive" type="xs:boolean" use="optional" default="false"/>
+				<xs:attribute name="exec_on" type="action_cond_t" use="optional" default="success"/>
+				<xs:attribute name="update_retcode" type="xs:boolean" use="optional" default="true"/>
+				<xs:attribute name="permanent" type="xs:boolean" use="optional" default="false"/>
+				<xs:attribute name="sync" type="xs:boolean" use="optional" default="false"/>
+			</xs:extension>
+		</xs:simpleContent>
+	</xs:complexType>
+
+
 <!--
 *******************************************************
 * <ENTRY> This tag is used to define wide class of elements.
@@ -261,45 +358,6 @@
 	</xs:complexType>
 
 
-<!--
-*******************************************************
-* <STARTUP> is used to define what happens when the CLI
-* is started. Any text held in a <DETAIL> sub-element will
-* be used as banner text, then any defined <ACTION> will be 
-* executed. This action may provide Message Of The Day (MOTD)
-* type behaviour.
-*
-* view - defines the view which will be transitioned to, on 
-*	successful execution of any <ACTION> tag.
-*
-* [viewid] - defined the new value of the ${VIEWID} variable to
-*	be used if a transition to a new view occurs.
-*
-* [default_shebang] - The default shebang for all commands.
-*
-* [timeout] - The idle timeout. The clish will exit if user
-*	have not press any key while this timeout.
-*
-* [lock] - The same as lock for COMMAND tag.
-*
-* [interrupt] - The same as interrupt for COMMAND tag.
-*
-* [default_plugin] - Use (or don't use) default plugin.
-*	It can be true or false.
-********************************************************
--->
-	<xs:complexType name="startup_t">
-		<xs:sequence>
-			<xs:element ref="ACTION" minOccurs="0" maxOccurs="unbounded"/>
-		</xs:sequence>
-		<xs:attribute name="view" type="xs:string" use="required"/>
-		<xs:attribute name="viewid" type="xs:string" use="optional"/>
-		<xs:attribute name="default_shebang" type="xs:string" use="optional"/>
-		<xs:attribute name="timeout" type="xs:string" use="optional"/>
-		<xs:attribute name="default_plugin" type="xs:boolean" use="optional" default="true"/>
-	</xs:complexType>
-
-
 <!--
 *******************************************************
 * <PARAM> This tag is used to define a parameter for a command.
@@ -374,75 +432,6 @@
 	</xs:complexType>
 
 
-<!--
-********************************************************
-* <ACTION> specifies the action to be taken for
-* a command.
-*
-* In addition the optional 'sym' attribute can specify
-* the name of an internal command which will be invoked
-* to handle script.
-*
-* [sym="<symbol>"] - specify the name of an internally registered
-*	function. The content of the ACTION tag is
-*	taken as the arguments to this builtin function.
-*
-* [lock="<name>"] - Named lock. It will use special lockfile while
-*	action execution.
-*
-* [interrupt="true/false"] - The boolean field that specify that action can be
-*	be interrupted by Ctrl^C. Default is false. Ignored for non-interactive
-*	actions.
-*
-* [interactive="true/false"] - Is action interactive.
-*
-* [exec_on="fail/success/always/never"] - ACTION's execution depends on
-*	return code of previous elements of ACTION chain. If the
-*	condition is not met then ACTION will not be executed. The "always"
-*	value means that ACTION will be always executed and chain return
-*	code will be ignored. Default is "success".
-*
-* [update_retcode="true/false"] - The chain return value can be updated
-*	by current ACTION's return code or ACTION's return code can be ignored.
-*	Default is "true".
-*
-* [permanent="true/false"] - The klish can be invoked with dry-run option. In
-*	this case all ACTIONs will be not actually executed but will always
-*	return success. But some actions like navigation is necessary to be
-*	executed in any case. Permanent flag will inform engine to always
-*	execute ACTION.
-*
-* [sync="true/false"] - Common behaviour is to fork() process before ACTION
-*	execution. But ACTION may be executed in-place (without fork()) if sync
-*	flag is set to true. It's not recommended to use sync ACTIONs widely.
-*	It's usefull for small fast functions only.
-*
-********************************************************
--->
-	<xs:simpleType name="action_cond_t">
-		<xs:restriction base="xs:string">
-			<xs:enumeration value="fail"/>
-			<xs:enumeration value="success"/>
-			<xs:enumeration value="always"/>
-			<xs:enumeration value="never"/>
-		</xs:restriction>
-	</xs:simpleType>
-
-	<xs:complexType name="action_t">
-		<xs:simpleContent>
-			<xs:extension base="xs:string">
-				<xs:attribute name="sym" type="xs:string" use="optional"/>
-				<xs:attribute name="lock" type="xs:string" use="optional"/>
-				<xs:attribute name="interrupt" type="xs:boolean" use="optional" default="false"/>
-				<xs:attribute name="interactive" type="xs:boolean" use="optional" default="false"/>
-				<xs:attribute name="exec_on" type="action_cond_t" use="optional" default="success"/>
-				<xs:attribute name="update_retcode" type="xs:boolean" use="optional" default="true"/>
-				<xs:attribute name="permanent" type="xs:boolean" use="optional" default="false"/>
-				<xs:attribute name="sync" type="xs:boolean" use="optional" default="false"/>
-			</xs:extension>
-		</xs:simpleContent>
-	</xs:complexType>
-
 
 <!--
 *******************************************************
@@ -611,16 +600,6 @@
 	</xs:complexType>
 
 
-<!--
-*******************************************************
-* <HOTKEY> is used to define hotkey actions
-*
-********************************************************
--->
-	<xs:complexType name="hotkey_t">
-		<xs:attribute name="key" type="xs:string" use="required"/>
-		<xs:attribute name="cmd" type="xs:string" use="required"/>
-	</xs:complexType>