summaryrefslogtreecommitdiffstats
path: root/lmi/scripts/common/command/multiplexer.py
diff options
context:
space:
mode:
authorMichal Minar <miminar@redhat.com>2014-02-02 11:24:29 +0100
committerMichal Minar <miminar@redhat.com>2014-02-05 14:44:04 +0100
commite893f9c76ec881fc13072d47696fe89e9cecdeb5 (patch)
treec70899acb88e2e4f893b256b37e074f61f3e440d /lmi/scripts/common/command/multiplexer.py
parent3ce60a9be48da5e32d47f1cda810bded671d8b74 (diff)
downloadopenlmi-scripts-e893f9c76ec881fc13072d47696fe89e9cecdeb5.tar.gz
openlmi-scripts-e893f9c76ec881fc13072d47696fe89e9cecdeb5.tar.xz
openlmi-scripts-e893f9c76ec881fc13072d47696fe89e9cecdeb5.zip
redone interactive mode
* Added support for changing to command namespace. Example: $ lmi lmi> :cd sw >sw> help ... >sw> :cd list >>list> pkgs >>list> :pwd /lmi/sw/list >>list> :cd / lmi> * Help and usage messages are now unindented. Resolves ticket #223
Diffstat (limited to 'lmi/scripts/common/command/multiplexer.py')
-rw-r--r--lmi/scripts/common/command/multiplexer.py16
1 files changed, 9 insertions, 7 deletions
diff --git a/lmi/scripts/common/command/multiplexer.py b/lmi/scripts/common/command/multiplexer.py
index 96e7027..f08422d 100644
--- a/lmi/scripts/common/command/multiplexer.py
+++ b/lmi/scripts/common/command/multiplexer.py
@@ -130,14 +130,16 @@ class LmiCommandMultiplexer(base.LmiBaseCommand):
"""
if not isinstance(args, (list, tuple)):
raise TypeError("args must be a list")
- full_args = self.cmd_name_args[1:] + args
- # check the --help ourselves (the default docopt behaviour checks
- # also for --version)
+ full_args = self.get_cmd_name_parts(for_docopt=True) + args
docopt_kwargs = {
- 'help' : False,
- # let's ignore options following first command for generated
- # usage string
- 'options_first' : not self.has_own_usage()
+ # check the --help ourselves (the default docopt behaviour checks
+ # also for --version)
+ 'help' : False,
+ # let's ignore options following first command for generated
+ # usage string and when a height of this branch is > 2
+ 'options_first' : not self.has_own_usage()
+ or any( not cmd.is_end_point()
+ for cmd in self.child_commands().values())
}
options = docopt(self.get_usage(), full_args, **docopt_kwargs)
if options.pop('--help', False):