0543266c92
- Restructuring of the project directory into client and server components - Renaming of modules and classes to better reflect their purpose and functionality - Moving common utilities and configurations to a shared location - Updating import statements to reflect the new structure - Adding new documentation files for better clarity on various aspects of the project - Removing deprecated or unused code to streamline the codebase - Ensuring that all existing functionality is preserved and that the codebase remains functional after the refactoring.
55 lines
1.4 KiB
Python
55 lines
1.4 KiB
Python
"""Command line interface for hbd package."""
|
|
|
|
import argparse
|
|
|
|
from .config import load_config
|
|
from .main import run as run_server
|
|
|
|
PUSHSRVS = ["all", "pushover", "mattermost"]
|
|
|
|
|
|
def build_parser():
|
|
parser = argparse.ArgumentParser(
|
|
prog="hbd",
|
|
description="HeartBeatDaemon - Wait for heartbeat messages and act on them (or their absence)",
|
|
formatter_class=argparse.RawDescriptionHelpFormatter,
|
|
)
|
|
parser.add_argument(
|
|
"-c", "--config", dest="configfile", help="Config file path (YAML)"
|
|
)
|
|
parser.add_argument(
|
|
"-f", "--foreground", action="store_true", help="Run in foreground"
|
|
)
|
|
parser.add_argument("-v", "--verbose", action="store_true", help="Verbose output")
|
|
parser.add_argument(
|
|
"-p", "--pushsrv", dest="pushsrv", choices=PUSHSRVS, help="Push service to use"
|
|
)
|
|
parser.add_argument(
|
|
"-x", "--debug", action="count", default=0, help="Increase debug level"
|
|
)
|
|
return parser
|
|
|
|
|
|
def main(argv=None):
|
|
parser = build_parser()
|
|
args = parser.parse_args(argv)
|
|
|
|
config = load_config(args.configfile)
|
|
|
|
# Apply CLI overrides
|
|
if args.foreground:
|
|
config["foreground"] = True
|
|
if args.verbose:
|
|
config["verbose"] = True
|
|
if args.pushsrv:
|
|
config["pushsrv"] = args.pushsrv
|
|
if args.debug:
|
|
config.setdefault("debug", 0)
|
|
config["debug"] += args.debug
|
|
|
|
run_server(config)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|