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 | 131e1d20bd9b23a5fc6094bf787a8facd2af6bab (patch) | |
tree | 0824b21cde96fe9701c3846d686d3bcd8339967b /coverage/cmdline.py | |
parent | d5d41e59b5bcc476ee0d7fd7e1f84deca164ec8a (diff) | |
download | python-coveragepy-git-131e1d20bd9b23a5fc6094bf787a8facd2af6bab.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 a22377cd..8c6688a8 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:]) |