[virt-tools-list] [virt-manager] [PATCH v2 2/2] cli: Use function cli_flag_name to help to concatenate '--' and cli_arg_name
Lin Ma
lma at suse.com
Mon Jan 14 09:21:34 UTC 2019
It can convert the underscore to minus for cli_arg_name in help output or error
message.
Signed-off-by: Lin Ma <lma at suse.com>
---
virt-xml | 2 +-
virtinst/cli.py | 12 ++++++------
2 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/virt-xml b/virt-xml
index e839b294..43048cd9 100755
--- a/virt-xml
+++ b/virt-xml
@@ -167,7 +167,7 @@ def check_xmlopt_collision(options):
if len(collisions) != 1:
fail(_("Only one change operation may be specified "
"(conflicting options %s)") %
- ["--" + c.cli_arg_name for c in collisions])
+ [c.cli_flag_name() for c in collisions])
return collisions[0]
diff --git a/virtinst/cli.py b/virtinst/cli.py
index fcf3fee2..111491e5 100644
--- a/virtinst/cli.py
+++ b/virtinst/cli.py
@@ -501,7 +501,7 @@ def autocomplete(parser):
import argcomplete
- parsernames = ["--" + pclass.cli_arg_name for pclass in
+ parsernames = [pclass.cli_flag_name() for pclass in
_get_completer_parsers()]
# pylint: disable=protected-access
for action in parser._actions:
@@ -1207,7 +1207,7 @@ class VirtCLIParser(metaclass=InitClass):
"""
Print out all _param names, triggered via ex. --disk help
"""
- print("--%s options:" % cls.cli_arg_name)
+ print("%s options:" % cls.cli_flag_name())
for arg in sorted(cls._virtargs, key=lambda p: p.cliname):
print(" %s" % arg.cliname)
print("")
@@ -1253,8 +1253,8 @@ class VirtCLIParser(metaclass=InitClass):
Callback that handles virt-xml clearxml=yes|no magic
"""
if not self.propname:
- raise RuntimeError("Don't know how to clearxml --%s" %
- self.cli_arg_name)
+ raise RuntimeError("Don't know how to clearxml %s" %
+ self.cli_flag_name())
if val is not True:
return
@@ -1318,8 +1318,8 @@ class VirtCLIParser(metaclass=InitClass):
passed an invalid argument such as --disk idontexist=foo
"""
if optdict:
- fail(_("Unknown --%s options: %s") %
- (self.cli_arg_name, list(optdict.keys())))
+ fail(_("Unknown %s options: %s") %
+ (self.cli_flag_name(), list(optdict.keys())))
def _parse(self, inst):
"""
--
2.19.0
More information about the virt-tools-list
mailing list