From 39683d80f2aea8412b805aa71a41e625c388b223 Mon Sep 17 00:00:00 2001 From: Ben Finney Date: Sun, 18 Oct 2015 12:58:20 +1100 Subject: =?UTF-8?q?Override=20program=20name=20only=20for=20=E2=80=98CmdOp?= =?UTF-8?q?tionParser=E2=80=99=20instances.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 94bb75f2..308dbacc 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