mingjiagu

  C++博客 :: 首页 :: 联系 :: 聚合  :: 管理
  5 Posts :: 0 Stories :: 1 Comments :: 0 Trackbacks

常用链接

留言簿(12)

我参与的团队

搜索

  •  

最新评论

阅读排行榜

评论排行榜

CLI Command XML

It is known that Clish can execute the command correctly by defining the right xml files .Here is the schema about CLI command xml I studied below:

For XML syntax can be understood by Clish, we must put the following at the top of our XML files.

XML Syntax

A entire xml file should express itself with right syntax. A complete xml file should contain  the following tags below:

Description

The VIEW is a top level XML element and it may contain one or more COMMAND XML elements.  These COMMAND   elements define the configuration mode commands.

Attributes

name   An identifier for the view

 prompt The prompt  will be  displayed on the CLI when this view is entered on the CLI.

Description

This XML element is used to indicate the name of the CLI command.

Attributes

name  The name means that the command name of The CLI command.

help The help text about the command.

view – The CLI view that will be switched to when the command is executed. This is used for the mode-change commands.

Example

When the command named-view executed, Clish will switch to the view named-view and user can go on configuring by using the command defined in the view named-view. Here is the result I used the command named-view: When I execute this command, it will enter the view “named-view” and I can used the command show defined in named-view to go on displaying the info on the screen .

PARAM

Description

This xml element is used as the value the CLI command will expect and CLI command may have more than one parameters.

Attributes

name – The name of the parameter

help – The help text about the parameter

ptype – A CLI command type. This element can enforce us to input the right parameter value, otherwise we can’t execute the command correctly. The parameter is defined in the types.xml.

Example

There are four parameters behind the command clock set. When we input right parameters, it only can execute the command correctly. Once we input incorrect parameters, Clish will remind us to input the right parameters. Here is the executed result below:

When I input the command clock set without any parameter, Clish will remind me to input the time. This command clock set need four parameters behind it, if we miss any one, this command can’t be executed.

Description

This element indicates that it is a new CLI type and used to enforce the value the parameter must have, it is associated with ptype of the element PARAM.

Attributes

name The name of the CLI type

method – “select” from a list, “integer”, not mandatory

pattern  a regex pattern enforcing user to input the right parameters

help – the help text about PTYPE

Example

 

The PTYPE DAY_MONTH will ask user to enter the value of day of month from 0 to 31, other value will be wrong. The PTYPE MONTH_NAME will require us to input the value of month from a list of 12 months. The same meaning with the PTYE TZ_NAME, YYYY_YEAR and TIME_HOURS.                                                                     

 

From the executed result above, when I try to input the value of day of moth with ‘32’, Clish reminds me input the value from 0 to 31.

ACTION

Description

The XML element ACTION is a sub-element of COMMAND. The ACTION XML element is used to specify the action associated with a CLI command. After the command is executed, the ACTION will be executed.

Attributes

None

Example

The command clock timezone above defines the time zone and time zone name. This ACTION calls echo shell to display time zone on the screen. Here is the executed result below:

When I executed the command clock timezone correctly, the ACTION called echo shell to display the time zone information I just configured on the screen.

 

 

posted on 2011-10-10 09:49 mousegu 阅读(937) 评论(0)  编辑 收藏 引用

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理