tools: fix handling single optional VM name
This commit is contained in:
parent
ee81902979
commit
7f5fc6ac3d
@ -163,11 +163,19 @@ class VmNameAction(QubesAction):
|
||||
if hasattr(namespace, 'exclude') and namespace.exclude:
|
||||
parser.error('--exclude can only be used with --all')
|
||||
|
||||
for vm_name in getattr(namespace, self.dest):
|
||||
try:
|
||||
namespace.domains += [app.domains[vm_name]]
|
||||
except KeyError:
|
||||
parser.error('no such domain: {!r}'.format(vm_name))
|
||||
if self.nargs == argparse.OPTIONAL:
|
||||
vm_name = getattr(namespace, self.dest, None)
|
||||
if vm_name is not None:
|
||||
try:
|
||||
namespace.domains += [app.domains[vm_name]]
|
||||
except KeyError:
|
||||
parser.error('no such domain: {!r}'.format(vm_name))
|
||||
else:
|
||||
for vm_name in getattr(namespace, self.dest):
|
||||
try:
|
||||
namespace.domains += [app.domains[vm_name]]
|
||||
except KeyError:
|
||||
parser.error('no such domain: {!r}'.format(vm_name))
|
||||
|
||||
|
||||
class RunningVmNameAction(VmNameAction):
|
||||
|
Loading…
Reference in New Issue
Block a user