Compare commits
2 Commits
0dd149121c
...
3e9d362805
Author | SHA1 | Date | |
---|---|---|---|
3e9d362805 | |||
256529373d |
@ -151,7 +151,7 @@ class Icinga2ConfAction(argparse.Action):
|
|||||||
help=help,
|
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:
|
for action in parser._actions:
|
||||||
if action.dest in [self.dest, "help", "version"] or isinstance(
|
if action.dest in [self.dest, "help", "version"] or isinstance(
|
||||||
action, argparse._SubParsersAction
|
action, argparse._SubParsersAction
|
||||||
@ -178,6 +178,10 @@ class Icinga2ConfAction(argparse.Action):
|
|||||||
print(f' value = "${param_prefix}_{icinga2_var}$"')
|
print(f' value = "${param_prefix}_{icinga2_var}$"')
|
||||||
|
|
||||||
print(f' description = "{action.help}"')
|
print(f' description = "{action.help}"')
|
||||||
|
|
||||||
|
if order is not None:
|
||||||
|
print(f' order = {order}')
|
||||||
|
|
||||||
print(" }")
|
print(" }")
|
||||||
|
|
||||||
def __call__(
|
def __call__(
|
||||||
@ -194,12 +198,16 @@ class Icinga2ConfAction(argparse.Action):
|
|||||||
for subname, subparser in choices.items():
|
for subname, subparser in choices.items():
|
||||||
print(f'object CheckCommand "{command_name}_{subname}" {{')
|
print(f'object CheckCommand "{command_name}_{subname}" {{')
|
||||||
print(
|
print(
|
||||||
f' command = [ PluginContribDir + "/{command_path}", "{subname}" ]'
|
f' command = [ PluginContribDir + "/{command_path}" ]'
|
||||||
)
|
)
|
||||||
|
|
||||||
print(" arguments = {")
|
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)
|
self._format_actions(f"{command_name}_{subname}", subparser)
|
||||||
|
|
||||||
print(" }\n}")
|
print(" }\n}")
|
||||||
|
Loading…
Reference in New Issue
Block a user