clan-core/pkgs/clan-cli/tests/helpers/cli.py
Qubasa 3351f87a7f
All checks were successful
checks-impure / test (pull_request) Successful in 1m22s
checks / test (pull_request) Successful in 2m52s
Removed duplicate logging messages
2024-01-11 22:46:29 +01:00

20 lines
504 B
Python

import argparse
import logging
import shlex
from clan_cli import create_parser
from clan_cli.custom_logger import get_caller
log = logging.getLogger(__name__)
class Cli:
def run(self, args: list[str]) -> argparse.Namespace:
parser = create_parser(prog="clan")
parsed = parser.parse_args(args)
cmd = shlex.join(["clan", *args])
log.debug(f"$ {cmd} \nCaller: {get_caller()}")
if hasattr(parsed, "func"):
parsed.func(parsed)
return parsed