This is a simple CLI command interpreter that can be used both in
interactive or non-interactive modes. It is based on a tree of ConfigNode
objects, which can be navigated.
The ConfigShell object itself provides global navigation commands. It
also handles the parsing of local commands (specific to a certain
ConfigNode) according to the ConfigNode commands definitions. If the
ConfigNode provides hooks for possible parameter values in a given
context, then the ConfigShell will also provide command-line completion
using the TAB key. If no completion hooks are available from the
ConfigNode, the completion function will still be able to display some
help and general syntax advice (as much as the ConfigNode will
provide).
Interactive sessions can be saved/loaded automatically by ConfigShell
is a writable session directory is supplied. This includes command-line
history, current node and global parameters.
|
__init__(self,
preferences_dir=None)
Creates a new ConfigShell. |
|
|
|
|
list of str
|
_complete_token_command(self,
text,
path,
command)
Completes a partial command token, which could also be the beginning
of a path. |
|
|
list of str
|
|
list of str
|
_complete_token_pparam(self,
text,
path,
command,
pparams,
kparams)
Completes a positional parameter token, which can also be the keywork
part of a kparam token, as before the '=' sign is on the line, the
parser cannot know better. |
|
|
list of str
|
_complete_token_kparam(self,
text,
path,
command,
pparams,
kparams)
Completes a keyword=value parameter token. |
|
|
str
|
_complete(self,
text,
state)
Text completion method, directly called by readline. |
|
|
list of str
|
_dispatch_completion(self,
path,
command,
pparams,
kparams,
text,
current_token)
This method takes care of dispatching the current completion request
from readline (via the _complete() method) to the relevant token
completion methods. |
|
|
|
_get_prompt(self)
Returns the command prompt string. |
|
|
|
_cli_loop(self)
Starts the configuration shell interactive loop, that: |
|
|
(pyparsing.ParseResults, str, str, list, dict)
|
_parse_cmdline(self,
line)
Parses the command line entered by the user. |
|
|
|
_execute_command(self,
path,
command,
pparams,
kparams)
Calls the target node to execute a command. |
|
|
|
|
|
run_script(self,
script_path,
exit_on_error=True)
Runs the script located at script_path. |
|
|
|
run_stdin(self,
file_descriptor=sys.stdin,
exit_on_error=True)
Reads commands to be run from a file descriptor, stdin by default. |
|
|
|
run_interactive(self)
Starts interactive CLI mode. |
|
|
|
|
Inherited from object :
__delattr__ ,
__format__ ,
__getattribute__ ,
__hash__ ,
__new__ ,
__reduce__ ,
__reduce_ex__ ,
__repr__ ,
__setattr__ ,
__sizeof__ ,
__str__ ,
__subclasshook__
|