diff options
author | Ned Batchelder <ned@nedbatchelder.com> | 2009-04-28 22:48:17 -0400 |
---|---|---|
committer | Ned Batchelder <ned@nedbatchelder.com> | 2009-04-28 22:48:17 -0400 |
commit | d02187a2cbd5cfda6539ee8ec2b073197618384d (patch) | |
tree | d42872f0b343859e2f0513b20979e0c3761b264a /coverage/cmdline.py | |
parent | c740ba3e236b53a4de89f390c4588e519ae94c1f (diff) | |
download | python-coveragepy-d02187a2cbd5cfda6539ee8ec2b073197618384d.tar.gz |
Don't spew the whole help message when there's a problem with command-line arguments.
Diffstat (limited to 'coverage/cmdline.py')
-rw-r--r-- | coverage/cmdline.py | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/coverage/cmdline.py b/coverage/cmdline.py index a22377c..8c6688a 100644 --- a/coverage/cmdline.py +++ b/coverage/cmdline.py @@ -52,18 +52,28 @@ COVERAGE_FILE environment variable to save it somewhere else. class CoverageScript: + """The command-line interface to coverage.py""" + def __init__(self): import coverage self.covpkg = coverage self.coverage = coverage.coverage() - def help(self, error=None): #pragma: no cover + def help(self, error=None): + """Display an error message, or the usage for coverage.py.""" if error: print error - print - print USAGE % self.covpkg.__dict__ + print "Use -h for help." + else: + print USAGE % self.covpkg.__dict__ def command_line(self, argv, help_fn=None): + """The bulk of the command line interface to coverage.py. + + `argv` is the argument list to process. + `help_fn` is the help function to use when something goes wrong. + + """ # Collect the command-line options. help_fn = help_fn or self.help OK, ERR = 0, 1 @@ -167,7 +177,11 @@ class CoverageScript: return OK -# Main entrypoint. This is installed as the script entrypoint, so don't -# refactor it away... + def main(): + """The main entrypoint to coverage.py. + + This is installed as the script entrypoint. + + """ return CoverageScript().command_line(sys.argv[1:]) |