From 0e302d3d3a8e85e85ec35726b907d2c3b0f77326 Mon Sep 17 00:00:00 2001
From: Mark Seger <Mark.Seger@hp.com>
Date: Wed, 25 Jun 2014 12:34:38 +0000
Subject: [PATCH] Add context sensitive help

Change-Id: I9aaadbaba2c43a12a83f8200eaaa96f48c52028e
---
 swiftclient/shell.py | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/swiftclient/shell.py b/swiftclient/shell.py
index d0353883..d10fc70a 100755
--- a/swiftclient/shell.py
+++ b/swiftclient/shell.py
@@ -1292,6 +1292,25 @@ 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
 
@@ -1335,7 +1354,7 @@ usage: %%prog [--version] [--help] [--snet] [--verbose]
              [--os-endpoint-type <endpoint-type>]
              [--os-cacert <ca-certificate>] [--insecure]
              [--no-ssl-compression]
-             <subcommand> ...
+             <subcommand> [--help]
 
 Command-line interface to the OpenStack Swift API.
 
@@ -1354,6 +1373,8 @@ Positional arguments:
 
 
 Examples:
+  %%prog download --help
+
   %%prog -A https://auth.api.rackspacecloud.com/v1.0 -U user -K api_key stat -v
 
   %%prog --os-auth-url https://api.example.com/v2.0 --os-tenant-name tenant \\