1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
|
"""DEPRECATED: Bulk execution of Zabbix commands."""
from __future__ import annotations
import subprocess
from pathlib import Path
from typing import Optional
import typer
from zabbix_cli.output.console import exit_err
from zabbix_cli.output.console import warning
app = typer.Typer(
name="zabbix-cli-bulk-execution", help="Bulk execution of Zabbix commands"
)
@app.callback(invoke_without_command=True)
def main_callback(
ctx: typer.Context,
input_file: Optional[Path] = typer.Argument(
None,
help="File to read commands from.",
),
config_file: Optional[Path] = typer.Option(
None,
"--config",
"-c",
help="Alternate configuration file to use.",
),
input_file_legacy: Optional[Path] = typer.Option(
None,
"--file",
"--input-file",
"-f",
hidden=True,
help="File to read commands from.",
),
) -> None:
warning(
"zabbix-cli-bulk-execution is deprecated. Use [command]zabbix-cli --file[/] instead."
)
f = input_file or input_file_legacy
if not f:
exit_err("No input file provided. Reading from stdin is not supported.")
# HACK: run the CLI with the file argument
args = ["zabbix-cli", "--file", str(f)]
if config_file:
args.extend(["--config", str(config_file)])
subprocess.run(args)
def main() -> None:
"""Main entry point for the CLI."""
app()
if __name__ == "__main__":
main()
|