Skip to contentSkip to conversation

Fix a few rough spots in StGIT's help command

PATCH New Karl Hasselström 1 participant 4 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

cover Fix a few rough spots in StGIT's help command

This series fixes a few irritating things in StGIT's online help. I post them as three independent patches since these are somewhat subjective improvements; feel free to drop the ones you don't like.

Signature · 2 lines
Karl Hasselström, [email protected]
      www.treskal.com/kalle
#1 lore raw

PATCH 1/3 Let "stg help" be like "stg --help"

From: Karl Hasselström <[email protected]>

"stg --help" prints the list of commands, but "stg help" just prints the usage message for the help command. This may be useful in theory, but the distinction is probably lost on 95% of all users (and the remaining 5% probably don't need to see the usage message for the help command anyway, since they know how it works). So just make both commands output the helpful command list.

---

 stgit/main.py |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)
stgit/main.py +1 -2
index de35ca8..66128a3 100644
@@ -226,8 +226,7 @@ def main():
                                   option_list = command.options)
             parser.print_help()
         else:
-            print 'usage: %s help <command>' % prog
-
+            print_help()
         sys.exit(0)
     if cmd in ['-v', '--version', 'version']:
         print 'Stacked GIT %s' % version
#2 lore raw

PATCH 2/3 When no command was given, print usage message

In reply to Karl Hasselström

From: Karl Hasselström <[email protected]>

It's just silly to say "Unknown command" when the user didn't give a command. Better to tell her to use a command.

---

 stgit/main.py |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
stgit/main.py +1 -1
index 66128a3..02d1eb1 100644
@@ -198,7 +198,7 @@ def main():
     prog = os.path.basename(sys.argv[0])
 
     if len(sys.argv) < 2:
-        print >> sys.stderr, 'Unknown command'
+        print >> sys.stderr, 'usage: %s <command>' % prog
         print >> sys.stderr, \
               '  Try "%s --help" for a list of supported commands' % prog
         sys.exit(1)
#3 lore raw

PATCH 3/3 Disregard extraneous arguments when providing help

In reply to Karl Hasselström

From: Karl Hasselström <[email protected]>

"stg --help pop" prints the help text for pop, but "stg --help pop foo" just prints the list of commands. That's silly, so fix it by simply ignoring the extra arguments.

---

 stgit/main.py |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
stgit/main.py +1 -1
index 02d1eb1..9fa0afc 100644
@@ -206,7 +206,7 @@ def main():
     cmd = sys.argv[1]
 
     if cmd in ['-h', '--help']:
-        if len(sys.argv) == 3 and sys.argv[2] in commands:
+        if len(sys.argv) >= 3 and sys.argv[2] in commands:
             cmd = sys.argv[2]
             sys.argv[2] = '--help'
         else: