Skip to contentSkip to conversation

Treat "stg --help cmd" and "stg help cmd" like "stg cmd --help"

PATCH New Pavel Roskin 1 participant 1 message Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Treat "stg --help cmd" and "stg help cmd" like "stg cmd --help"

User's intention is perfectly clear if "-h", "--help" or "help" is followed by a valid command - show help for that command.

---

 stgit/main.py |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)
stgit/main.py +6 -2
index 2336a43..6d86ee4 100644
@@ -125,8 +125,12 @@ def main():
     cmd = sys.argv[1]
 
     if cmd in ['-h', '--help', 'help']:
-        print_help()
-        sys.exit(0)
+        if len(sys.argv) == 3 and sys.argv[2] in commands:
+            cmd = sys.argv[2]
+            sys.argv[2] = '--help';
+        else:
+            print_help()
+            sys.exit(0)
     if cmd in ['-v', '--version', 'version']:
         print 'Stacked GIT %s' % version
         os.system('git --version')
Signature · 2 lines
Regards,
Pavel Roskin