From 4af13d5445b9bd8261a18220bc12d515af7ac02d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Fri, 22 Dec 2017 23:03:26 +0100 Subject: [PATCH] tools: fix handling optional domain list It wasn't possible to use QubesArgumentParser(vmname_nargs=...) for optional domain list - the option forced usage of either --all or explicit domain list. --- qubesadmin/tools/__init__.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/qubesadmin/tools/__init__.py b/qubesadmin/tools/__init__.py index 76067bd..bf47ea6 100644 --- a/qubesadmin/tools/__init__.py +++ b/qubesadmin/tools/__init__.py @@ -361,7 +361,9 @@ class QubesArgumentParser(argparse.ArgumentParser): default=False, help=argparse.SUPPRESS) if self._vmname_nargs in [argparse.ZERO_OR_MORE, argparse.ONE_OR_MORE]: - vm_name_group = VmNameGroup(self, self._vmname_nargs) + vm_name_group = VmNameGroup(self, + required=(self._vmname_nargs + not in [argparse.ZERO_OR_MORE, argparse.OPTIONAL])) self._mutually_exclusive_groups.append(vm_name_group) elif self._vmname_nargs is not None: self.add_argument('VMNAME', nargs=self._vmname_nargs,