Compare commits

..

2 Commits

Author SHA1 Message Date
3e9d362805 Bump version to 0.2.0 2022-12-30 23:49:05 -05:00
256529373d Add support for text/regex based attributes 2022-12-30 23:49:05 -05:00

View File

@ -151,7 +151,7 @@ class Icinga2ConfAction(argparse.Action):
help=help,
)
def _format_actions(self, param_prefix: str, parser: argparse.ArgumentParser):
def _format_actions(self, param_prefix: str, parser: argparse.ArgumentParser, order: Optional[int] = None):
for action in parser._actions:
if action.dest in [self.dest, "help", "version"] or isinstance(
action, argparse._SubParsersAction
@ -178,6 +178,10 @@ class Icinga2ConfAction(argparse.Action):
print(f' value = "${param_prefix}_{icinga2_var}$"')
print(f' description = "{action.help}"')
if order is not None:
print(f' order = {order}')
print(" }")
def __call__(
@ -194,12 +198,16 @@ class Icinga2ConfAction(argparse.Action):
for subname, subparser in choices.items():
print(f'object CheckCommand "{command_name}_{subname}" {{')
print(
f' command = [ PluginContribDir + "/{command_path}", "{subname}" ]'
f' command = [ PluginContribDir + "/{command_path}" ]'
)
print(" arguments = {")
self._format_actions(command_name, parser)
self._format_actions(command_name, parser, order=-2)
print(f' "{subname}" = {{')
print(' set_if = true')
print(' order = -1')
print(' }')
self._format_actions(f"{command_name}_{subname}", subparser)
print(" }\n}")