summaryrefslogtreecommitdiff
path: root/swiftclient
diff options
context:
space:
mode:
authorAlistair Coles <alistair.coles@hp.com>2014-07-10 11:29:42 +0100
committerSamuel Merritt <sam@swiftstack.com>2014-07-21 15:27:40 -0700
commit394cb57f630b3dfdc1d5b2e172ef0f1c16b8211f (patch)
tree2442cdf3eadd1f78f0613207651ace6e11a94de8 /swiftclient
parentf9ea672322cddba65bbcd5bd8bf7b83b583d4cb2 (diff)
downloadpython-swiftclient-2.2.0.tar.gz
Fix context sensitive help for info and tempurl2.2.0
Make it so that swift <cmd> --help will print the info subcommand help for info and tempurl just like all the other subcommands. Also add unit tests to verify subcommand help. Change-Id: Id3666dcf72a9727fbfda2f74c23293ada1c53aa0
Diffstat (limited to 'swiftclient')
-rwxr-xr-xswiftclient/shell.py31
1 files changed, 9 insertions, 22 deletions
diff --git a/swiftclient/shell.py b/swiftclient/shell.py
index 7ccde57..ef153c7 100755
--- a/swiftclient/shell.py
+++ b/swiftclient/shell.py
@@ -46,6 +46,8 @@ from swiftclient import __version__ as client_version
BASENAME = 'swift'
POLICY = 'X-Storage-Policy'
+commands = ('delete', 'download', 'list', 'post',
+ 'stat', 'upload', 'capabilities', 'info', 'tempurl')
def get_conn(options):
@@ -1244,7 +1246,7 @@ Retrieve capability of the proxy.
Optional positional arguments:
<proxy_url> Proxy URL of the cluster to retrieve capabilities.
-'''
+'''.strip('\n')
st_info_help = st_capabilities_help
@@ -1344,6 +1346,12 @@ def parse_args(parser, args, enforce_requires=True):
args = ['-h']
(options, args) = parser.parse_args(args)
+ if len(args) > 1 and args[1] == '--help':
+ _help = globals().get('st_%s_help' % args[0],
+ "no help for %s" % args[0])
+ print(_help)
+ exit()
+
# Short circuit for tempurl, which doesn't need auth
if len(args) > 0 and args[0] == 'tempurl':
return options, args
@@ -1371,25 +1379,6 @@ def parse_args(parser, args, enforce_requires=True):
'region_name': options.os_region_name,
}
- if len(args) > 1 and args[1] == '--help':
- if args[0] == 'capabilities':
- print(st_capabilities_help)
- elif args[0] == 'delete':
- print(st_delete_help)
- elif args[0] == 'download':
- print(st_download_help)
- elif args[0] == 'list':
- print(st_list_help)
- elif args[0] == 'post':
- print(st_post_help)
- elif args[0] == 'stat':
- print(st_stat_help)
- elif args[0] == 'upload':
- print(st_upload_help)
- else:
- print("no help for %s" % args[0])
- exit()
-
if len(args) > 1 and args[0] == "capabilities":
return options, args
@@ -1588,8 +1577,6 @@ Examples:
(options, args) = parse_args(parser, argv[1:], enforce_requires=False)
parser.enable_interspersed_args()
- commands = ('delete', 'download', 'list', 'post',
- 'stat', 'upload', 'capabilities', 'info', 'tempurl')
if not args or args[0] not in commands:
parser.print_usage()
if args: