2023-08-09 08:17:11 +00:00
|
|
|
import argparse
|
2023-10-16 13:03:53 +00:00
|
|
|
import logging
|
|
|
|
import shlex
|
2023-10-17 21:49:16 +00:00
|
|
|
|
|
|
|
from clan_cli import create_parser
|
2024-01-11 21:46:29 +00:00
|
|
|
from clan_cli.custom_logger import get_caller
|
2023-10-17 21:49:16 +00:00
|
|
|
|
2023-10-16 13:03:53 +00:00
|
|
|
log = logging.getLogger(__name__)
|
2023-08-09 08:17:11 +00:00
|
|
|
|
2023-10-16 13:19:25 +00:00
|
|
|
|
2023-08-24 15:29:31 +00:00
|
|
|
class Cli:
|
2023-08-09 08:17:11 +00:00
|
|
|
def run(self, args: list[str]) -> argparse.Namespace:
|
2023-11-15 13:28:40 +00:00
|
|
|
parser = create_parser(prog="clan")
|
2024-01-11 21:14:55 +00:00
|
|
|
parsed = parser.parse_args(args)
|
2024-01-11 21:46:29 +00:00
|
|
|
cmd = shlex.join(["clan", *args])
|
|
|
|
log.debug(f"$ {cmd} \nCaller: {get_caller()}")
|
2023-08-24 15:29:31 +00:00
|
|
|
if hasattr(parsed, "func"):
|
|
|
|
parsed.func(parsed)
|
2023-08-09 08:17:11 +00:00
|
|
|
return parsed
|