This function facilitates retrieving specific properties from a DBus interface, improving code modularity and reusability. It supports both system and session bus types, streamlining access to DBus resources.
61 lines
1.3 KiB
Python
61 lines
1.3 KiB
Python
# SPDX-FileCopyrightText: 2025 KUNBUS GmbH
|
|
# SPDX-License-Identifier: GPL-2.0-or-later
|
|
"""Command-line interface base module for RevPi middleware daemon.
|
|
|
|
This module provides the foundation for the RevPi middleware CLI commands
|
|
and argument parsing setup.
|
|
"""
|
|
from logging import getLogger
|
|
|
|
from . import cli_config, cli_picontrol
|
|
from .. import proginit as pi
|
|
from ..proginit import StdLogOutput
|
|
|
|
log = getLogger(__name__)
|
|
|
|
|
|
def setup_command_line_arguments():
|
|
pi.parser.prog = "revpictl"
|
|
|
|
# Add all objects here
|
|
rpictl_obj = pi.parser.add_subparsers(
|
|
dest="obj",
|
|
title="object",
|
|
help="Available RevPi objects",
|
|
)
|
|
|
|
obj_picontrol = rpictl_obj.add_parser(
|
|
"picontrol",
|
|
help="RevPi PiControl object",
|
|
)
|
|
cli_picontrol.add_subparsers(obj_picontrol)
|
|
obj_config = rpictl_obj.add_parser(
|
|
"config",
|
|
help="RevPi configuration object (revpi-config)",
|
|
)
|
|
cli_config.add_subparsers(obj_config)
|
|
|
|
|
|
def main() -> int:
|
|
setup_command_line_arguments()
|
|
pi.init_app(StdLogOutput.STDERR)
|
|
|
|
obj = pi.pargs.obj
|
|
if obj == "picontrol":
|
|
rc = cli_picontrol.main()
|
|
|
|
elif obj == "config":
|
|
rc = cli_config.main()
|
|
|
|
else:
|
|
log.error(f"Unknown object: {obj}")
|
|
rc = 1
|
|
|
|
pi.cleanup()
|
|
|
|
return rc
|
|
|
|
|
|
if __name__ == "__main__":
|
|
exit(main())
|