From 192aae2ee24eeacce209b208916528086ab3a229 Mon Sep 17 00:00:00 2001 From: Ben Finney Date: Sun, 18 Oct 2015 12:58:20 +1100 Subject: Override program name only for ?CmdOptionParser? instances. We only need to append the sub-command, so we shouldn't override the actual command. Get the command from the superclass. --- coverage/cmdline.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'coverage/cmdline.py') diff --git a/coverage/cmdline.py b/coverage/cmdline.py index 94bb75f..308dbac 100644 --- a/coverage/cmdline.py +++ b/coverage/cmdline.py @@ -230,7 +230,6 @@ class CmdOptionParser(CoverageOptionParser): if usage: usage = "%prog " + usage super(CmdOptionParser, self).__init__( - prog="%(program_name)s %s" % action, usage=usage, description=description, ) @@ -244,6 +243,15 @@ class CmdOptionParser(CoverageOptionParser): # results, and they will compare equal to objects. return (other == "" % self.cmd) + def get_prog_name(self): + program_name = super(CmdOptionParser, self).get_prog_name() + + # Include the sub-command for this parser as part of the command. + result = "%(command)s %(subcommand)s" % { + 'command': program_name, 'subcommand': self.cmd} + return result + + GLOBAL_ARGS = [ Opts.debug, Opts.help, -- cgit v1.2.1