Skip to content

Commit 131e1d2

Browse files
committed
Don't spew the whole help message when there's a problem with command-line arguments.
1 parent d5d41e5 commit 131e1d2

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

coverage/cmdline.py

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,18 +52,28 @@
5252

5353

5454
class CoverageScript:
55+
"""The command-line interface to coverage.py"""
56+
5557
def __init__(self):
5658
import coverage
5759
self.covpkg = coverage
5860
self.coverage = coverage.coverage()
5961

60-
def help(self, error=None): #pragma: no cover
62+
def help(self, error=None):
63+
"""Display an error message, or the usage for coverage.py."""
6164
if error:
6265
print error
63-
print
64-
print USAGE % self.covpkg.__dict__
66+
print "Use -h for help."
67+
else:
68+
print USAGE % self.covpkg.__dict__
6569

6670
def command_line(self, argv, help_fn=None):
71+
"""The bulk of the command line interface to coverage.py.
72+
73+
`argv` is the argument list to process.
74+
`help_fn` is the help function to use when something goes wrong.
75+
76+
"""
6777
# Collect the command-line options.
6878
help_fn = help_fn or self.help
6979
OK, ERR = 0, 1
@@ -167,7 +177,11 @@ def command_line(self, argv, help_fn=None):
167177

168178
return OK
169179

170-
# Main entrypoint. This is installed as the script entrypoint, so don't
171-
# refactor it away...
180+
172181
def main():
182+
"""The main entrypoint to coverage.py.
183+
184+
This is installed as the script entrypoint.
185+
186+
"""
173187
return CoverageScript().command_line(sys.argv[1:])

0 commit comments

Comments
 (0)