The CommandTree structure
-------------------------
-CommandTree manages a command by its path. Each command is stored in multiple nodes on the tree, so that the last term is a leaf and the route from root to that leaf represents the command path. For example the commands *store upload*, *store list* and *store info* are stored together as shown bellow::
+CommandTree manages a command by its path. Each command is stored in multiple nodes on the tree, so that the last term is a leaf and the route from root to that leaf represents the command path. For example the commands *file upload*, *file list* and *file info* are stored together as shown bellow::
- - store
+ - file
''''''''|- info
|- list
|- upload
def command(cmd_tree, prefix='', descedants_depth=None):
"""Load a class as a command
- @cmd_tree is the CommandTree to be updated with a new command
- @prefix of the commands allowed to be inserted ('' for all)
- @descedants_depth is the depth of the tree descedants of the
+ :param cmd_tree: is the CommandTree to be updated with a new command
+ :param prefix: of the commands allowed to be inserted ('' for all)
+ :param descedants_depth: is the depth of the tree descedants of the
prefix command.
"""
Declare run-time argument
-------------------------
-The argument mechanism allows the definition of run-time arguments. Some basic argument types are defined at the `argument module <cli.html#module-kamaki.cli.argument>`_, but it is not uncommon to extent these classes in order to achieve specialized type checking and syntax control (e.g. at `pithos_cli module <cli.html#module-kamaki.cli.commands.pithos_cli>`_).
+The argument mechanism allows the definition of run-time arguments. Some basic argument types are defined at the `argument module <code.html#module-kamaki.cli.argument>`_, but it is not uncommon to extent these classes in order to achieve specialized type checking and syntax control (e.g. at `pithos cli module <code.html#module-kamaki.cli.commands.pithos>`_).
To declare a run-time argument on a specific command, the object class should initialize a dict called *arguments* , where Argument objects are stored. Each argument object is a possible run-time argument. Syntax checking happens at client level, while the type checking is implemented in the Argument code (thus, many different Argument types might be needed).
class mygrp1_list_details():
"""list of details"""
- def __init__(self, global_args={})
+ def __init__(self, global_args={}):
global_args['match'] = ValueArgument(
'Filter results to match string',
'--match')
The command behavior for each command / class is coded in *main*. The parameters of *main* method defines the command parameters part of the syntax. In specific::
- main(self, param) - obligatory parameter
- main(self, param=None) - optional parameter
+ main(self, param) - obligatory parameter <param>
+ main(self, param=None) - optional parameter [param]
main(self, param1, param2=42) - <param1> [param2]
main(self, param1____param2) - <param1:param2>
main(self, param1____param2=[]) - [param1:param2]