File: run.py

package info (click to toggle)
zabbix-cli 3.6.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,980 kB
  • sloc: python: 19,920; makefile: 5
file content (30 lines) | stat: -rw-r--r-- 687 bytes parent folder | download | duplicates (2)
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
from __future__ import annotations

from enum import Enum
from pathlib import Path
from typing import Optional

import typer

from zabbix_cli.config.model import Config
from zabbix_cli.config.utils import get_config


class RunMode(str, Enum):
    SHOW = "show"
    DEFAULTS = "defaults"


def main(
    arg: RunMode = typer.Argument(RunMode.DEFAULTS, case_sensitive=False),
    filename: Optional[Path] = None,
):
    """Print current or default config to stdout."""
    from zabbix_cli.logs import configure_logging

    configure_logging()
    if arg == RunMode.SHOW:
        config = get_config(filename)
    else:
        config = Config.sample_config()
    print(config.as_toml())