# [PATCH 3/3] Disregard extraneous arguments when providing help

4 messages from 2006-10-22 to 2006-10-22. Participants: Karl Hasselström.
Thread: https://gitlist.dev/t/5998

## Karl Hasselström, 2006-10-22 13:02

Subject: [PATCH 0/3] Fix a few rough spots in StGIT's help command
Message-ID: <20061022130214.16449.41482.stgit@localhost>
URL: https://gitlist.dev/e/20061022130214.16449.41482.stgit%40localhost

```
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, 2006-10-22 13:05

Subject: [PATCH 1/3] Let "stg help" be like "stg --help"
Message-ID: <20061022130520.16449.70729.stgit@localhost>
URL: https://gitlist.dev/e/20061022130520.16449.70729.stgit%40localhost
In-Reply-To: <20061022130214.16449.41482.stgit@localhost>

```
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(-)

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, 2006-10-22 13:05

Subject: [PATCH 2/3] When no command was given, print usage message
Message-ID: <20061022130526.16449.81113.stgit@localhost>
URL: https://gitlist.dev/e/20061022130526.16449.81113.stgit%40localhost
In-Reply-To: <20061022130214.16449.41482.stgit@localhost>

```
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(-)

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, 2006-10-22 13:05

Subject: [PATCH 3/3] Disregard extraneous arguments when providing help
Message-ID: <20061022130531.16449.50598.stgit@localhost>
URL: https://gitlist.dev/e/20061022130531.16449.50598.stgit%40localhost
In-Reply-To: <20061022130214.16449.41482.stgit@localhost>

```
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(-)

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:

```
