summaryrefslogtreecommitdiff
path: root/glanceclient/shell.py
diff options
context:
space:
mode:
authorNiallBunting <niall.bunting@hpe.com>2015-12-08 17:28:14 +0000
committerNiallBunting <niall.bunting@hpe.com>2015-12-09 13:21:17 +0000
commitbf67b80dbff7c8fdb7e4dcaa11bd1809f0cf7566 (patch)
treef362669de29a1e64d7d75f5947681f167154ddc2 /glanceclient/shell.py
parentbe22b3923ba54ee6829217db9cf175e31c227b90 (diff)
downloadpython-glanceclient-bf67b80dbff7c8fdb7e4dcaa11bd1809f0cf7566.tar.gz
Disable suggestion of v1 help for v2 commands
Currently the client suggests 'Run `glance --os-image-api-version 1 help` for v1 help' at the end of every help message. This is could be confusing for a v2 only command. Therefore this patch disables it if the command does not exist in v1, while keeping the message on the 'glance help' results. Change-Id: I967e9ba35afb8dc40524bd1d13284e684b435f81 Closes-Bug: 1520602
Diffstat (limited to 'glanceclient/shell.py')
-rwxr-xr-xglanceclient/shell.py17
1 files changed, 14 insertions, 3 deletions
diff --git a/glanceclient/shell.py b/glanceclient/shell.py
index b0028ca..1b41cac 100755
--- a/glanceclient/shell.py
+++ b/glanceclient/shell.py
@@ -630,13 +630,24 @@ class OpenStackImagesShell(object):
else:
raise exc.CommandError("'%s' is not a valid subcommand" %
args.command)
- command = ' ' + command
else:
parser.print_help()
if not args.os_image_api_version or args.os_image_api_version == '2':
- print(("\nRun `glance --os-image-api-version 1 help%s`"
- " for v1 help") % (command or ''))
+ # NOTE(NiallBunting) This currently assumes that the only versions
+ # are one and two.
+ try:
+ if command is None:
+ print("\nRun `glance --os-image-api-version 1 help`"
+ " for v1 help")
+ else:
+ self.get_subcommand_parser(1)
+ if command in self.subcommands:
+ command = ' ' + command
+ print(("\nRun `glance --os-image-api-version 1 help%s`"
+ " for v1 help") % (command or ''))
+ except ImportError:
+ pass
def do_bash_completion(self, _args):
"""Prints arguments for bash_completion.