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:
|
if hasattr(namespace, 'exclude') and namespace.exclude:
|
||||||
parser.error('--exclude can only be used with --all')
|
parser.error('--exclude can only be used with --all')
|
||||||
|
|
||||||
for vm_name in getattr(namespace, self.dest):
|
if self.nargs == argparse.OPTIONAL:
|
||||||
try:
|
vm_name = getattr(namespace, self.dest, None)
|
||||||
namespace.domains += [app.domains[vm_name]]
|
if vm_name is not None:
|
||||||
except KeyError:
|
try:
|
||||||
parser.error('no such domain: {!r}'.format(vm_name))
|
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):
|
class RunningVmNameAction(VmNameAction):
|
||||||
|
Loading…
Reference in New Issue
Block a user