From 9b21f27e31afc1d26219f7ddfa222a65312eadbb Mon Sep 17 00:00:00 2001 From: Cole Robinson Date: Tue, 7 Apr 2015 19:58:28 -0400 Subject: [PATCH] cli: Maintain same --print-xml behavior for non virt-install Don't want it scooping up any nargs --- virt-install | 4 ---- virtinst/cli.py | 18 ++++++++++++++---- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/virt-install b/virt-install index 5b760e949..9f6cfe1e8 100755 --- a/virt-install +++ b/virt-install @@ -110,10 +110,6 @@ def convert_old_printxml(options): options.xmlonly = options.xmlstep del(options.xmlstep) - # The case when someone specifies a bare --print-xml - if options.xmlonly is True: - options.xmlonly = "all" - def convert_old_sound(options): if not options.sound: diff --git a/virtinst/cli.py b/virtinst/cli.py index 088bdf548..694ce7b9c 100644 --- a/virtinst/cli.py +++ b/virtinst/cli.py @@ -483,10 +483,20 @@ def add_misc_options(grp, prompt=False, replace=False, "with the same name.")) if printxml: - grp.add_argument("--print-xml", nargs="?", dest="xmlonly", - default=False, const=True, - help=_("Print the generated domain XML rather than create " - "the guest.")) + print_kwargs = { + "dest": "xmlonly", + "default": False, + "help": _("Print the generated domain XML rather than create " + "the guest."), + } + + if printstep: + print_kwargs["nargs"] = "?" + print_kwargs["const"] = "all" + else: + print_kwargs["action"] = "store_true" + + grp.add_argument("--print-xml", **print_kwargs) if printstep: # Back compat, argparse allows us to use --print-xml # for everything.