dockge-cli/dockge_cli/client/parser.py
Firq a99b81b0c7
All checks were successful
/ pylint (push) Successful in 11s
/ mypy (push) Successful in 13s
Pylint settings
2024-07-05 16:05:35 +02:00

23 lines
805 B
Python

import argparse
import sys
from .. import __version__
from ..models import Arguments
from .commandprovider.factory import commands
def parse_arguments():
"""
Create a parser and parse the arguments of sys.argv based on the Arguments Namespace
Returns arguments and extra arguments separately
"""
parser = argparse.ArgumentParser(
prog="dockge_cli",
description="CLI interface for interacting with Dockge",)
parser.add_argument("command", choices=list(commands.keys()), action="store", type=str, default=None)
parser.add_argument("--version", action="version", version=f"dockge_cli {__version__}")
args = Arguments()
args, extra_args = parser.parse_known_args(sys.argv[1:], namespace=args)
return args, extra_args