matrix-bot: Add argparse

add mautrix
This commit is contained in:
Qubasa
2024-06-13 18:45:36 +02:00
parent 881196188c
commit ef9b733631
7 changed files with 153 additions and 4 deletions

View File

@@ -1,3 +1,36 @@
import argparse
import logging
import sys
from matrix_bot.custom_logger import setup_logging
log = logging.getLogger(__name__)
def create_parser(prog: str | None = None) -> argparse.ArgumentParser:
parser = argparse.ArgumentParser(
prog=prog,
description="A gitea bot for matrix",
formatter_class=argparse.RawTextHelpFormatter,
)
parser.add_argument(
"--debug",
help="Enable debug logging",
action="store_true",
default=False,
)
return parser
def main():
print("Hello, world!")
parser = create_parser()
args = parser.parse_args()
if len(sys.argv) == 1:
parser.print_help()
if args.debug:
setup_logging(logging.DEBUG, root_log_name=__name__.split(".")[0])
log.debug("Debug log activated")
else:
setup_logging(logging.INFO, root_log_name=__name__.split(".")[0])