diff options
author | Michal Minar <miminar@redhat.com> | 2014-02-03 16:11:40 +0100 |
---|---|---|
committer | Michal Minar <miminar@redhat.com> | 2014-02-05 14:44:04 +0100 |
commit | 6855f2a18927375c94178f98c6de91d36f37186d (patch) | |
tree | ba4415910048f448b2cd9e8c5c1957bda21400d3 /lmi/scripts/common/command/multiplexer.py | |
parent | 381dc1f634554d97cb841efdbf5a0ff0c17d1237 (diff) | |
download | openlmi-scripts-6855f2a18927375c94178f98c6de91d36f37186d.tar.gz openlmi-scripts-6855f2a18927375c94178f98c6de91d36f37186d.tar.xz openlmi-scripts-6855f2a18927375c94178f98c6de91d36f37186d.zip |
improved help command
Help command behaves consistently in interactive and non-interactive
modes.
Following help requests are now possible:
lmi> help # shows available commands
lmi> help cmd # prints help of cmd command
lmi> help cmd subcmd # prints help of subcmd in cmd namespace
# if it has its own usage string
lmi> cmd --help # the same as help cmd
lmi> cmd subcmd --help # the same as help cmd subcmd
The same works in non-interactive mode.
Resolves tickets #226, #214
Diffstat (limited to 'lmi/scripts/common/command/multiplexer.py')
-rw-r--r-- | lmi/scripts/common/command/multiplexer.py | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/lmi/scripts/common/command/multiplexer.py b/lmi/scripts/common/command/multiplexer.py index f08422d..aa5fbad 100644 --- a/lmi/scripts/common/command/multiplexer.py +++ b/lmi/scripts/common/command/multiplexer.py @@ -142,8 +142,8 @@ class LmiCommandMultiplexer(base.LmiBaseCommand): for cmd in self.child_commands().values()) } options = docopt(self.get_usage(), full_args, **docopt_kwargs) - if options.pop('--help', False): - self.app.stdout.write(self.get_usage()) + if options.pop('--help', False) or (args and args[0] == '--help'): + self.app.stdout.write(self.get_usage(proper=True)) return 0 if ( self.fallback_command() is not None and (not args or args[0] not in self.child_commands())): |