threads / patch / 5998

patch, 3 partsDisregard extraneous arguments when providing help

Subject: [PATCH 3/3] Disregard extraneous arguments when providing help

## tl;dr

4 messages between Oct 22, 2006 and Oct 22, 2006. Diffs are folded; open one to read it.

replies: 3people: 1as markdown or json

Karl Hasselström· Oct 22, 2006, 13:02 UTC · lore

[PATCH 0/3] 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.

-- 
Karl Hasselström, kha@treskal.com
      www.treskal.com/kalle
Karl Hasselström· Oct 22, 2006, 13:05 UTC · re: Karl Hasselström · lore

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

From: Karl Hasselström <kha@treskal.com>

"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.

Signed-off-by: Karl Hasselström <kha@treskal.com>
---
 stgit/main.py |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)
Show changes to stgit/main.py +1 −2
diff --git a/stgit/main.py b/stgit/main.py
index de35ca8..66128a3 100644
--- a/stgit/main.py
+++ b/stgit/main.py
@@ -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
Karl Hasselström· Oct 22, 2006, 13:05 UTC · re: Karl Hasselström · lore

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

From: Karl Hasselström <kha@treskal.com>

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

Signed-off-by: Karl Hasselström <kha@treskal.com>
---
 stgit/main.py |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Show changes to stgit/main.py +1 −1
diff --git a/stgit/main.py b/stgit/main.py
index 66128a3..02d1eb1 100644
--- a/stgit/main.py
+++ b/stgit/main.py
@@ -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)
Karl Hasselström· Oct 22, 2006, 13:05 UTC · re: Karl Hasselström · lore
From: Karl Hasselström <kha@treskal.com>

"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.

Signed-off-by: Karl Hasselström <kha@treskal.com>
---
 stgit/main.py |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Show changes to stgit/main.py +1 −1
diff --git a/stgit/main.py b/stgit/main.py
index 02d1eb1..9fa0afc 100644
--- a/stgit/main.py
+++ b/stgit/main.py
@@ -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:

← back to recent threads