diff options
author | Michal Minar <miminar@redhat.com> | 2014-02-17 16:52:51 +0100 |
---|---|---|
committer | Michal Minar <miminar@redhat.com> | 2014-02-17 17:05:45 +0100 |
commit | 66ff49409f671d9325e705e69d256e80d7625b58 (patch) | |
tree | 70fb680fd72ecb08670109406b36be587ddf13fd /lmi/scripts/common/command/multiplexer.py | |
parent | 4130fd07bb27b447bdd230bf7323208379f007b6 (diff) | |
download | openlmi-scripts-66ff49409f671d9325e705e69d256e80d7625b58.tar.gz openlmi-scripts-66ff49409f671d9325e705e69d256e80d7625b58.tar.xz openlmi-scripts-66ff49409f671d9325e705e69d256e80d7625b58.zip |
fixed parsing of command line options
Docopt parser needs to be given options_first which causes that all
arguments are treated a positional after the first positional is given.
This allows for commands nesting with hierarchical usage.
Multiplexer used wrong heuristic for determining its value.
Diffstat (limited to 'lmi/scripts/common/command/multiplexer.py')
-rw-r--r-- | lmi/scripts/common/command/multiplexer.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/lmi/scripts/common/command/multiplexer.py b/lmi/scripts/common/command/multiplexer.py index 96ccd50..61ebcd7 100644 --- a/lmi/scripts/common/command/multiplexer.py +++ b/lmi/scripts/common/command/multiplexer.py @@ -139,7 +139,9 @@ class LmiCommandMultiplexer(base.LmiBaseCommand): # 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()) + for cmd in self.child_commands().values() + if not args or args[0] not in self.child_commands() + or self.child_commands()[args[0]] is cmd) } options = docopt(self.get_usage(), full_args, **docopt_kwargs) if options.pop('--help', False) or (args and args[0] == '--help'): |