kas: Simplify setup of plugin argument parsers

By defining the plugin name and help message as attributes of the plugin
class we can move the argument parser creation up into the
kas_get_argparser() function. This will allow us to further reduce
duplication in following commits.

Signed-off-by: Paul Barker <pbarker@konsulko.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
This commit is contained in:
Paul Barker
2020-06-15 22:03:27 +02:00
committed by Jan Kiszka
parent 23277836c4
commit a37d72ea7c
3 changed files with 38 additions and 36 deletions

View File

@@ -121,7 +121,8 @@ def kas_get_argparser():
ext_plugin.load()
for plugin in getattr(kasplugin, 'plugins', []):
plugin.get_argparser(subparser)
plugin_parser = subparser.add_parser(plugin.name, help=plugin.helpmsg)
plugin.setup_parser(plugin_parser)
return parser