22 lines
790 B
Python
22 lines
790 B
Python
import argparse
|
|
import sys
|
|
|
|
from .. import __version__
|
|
from ..models import Arguments
|
|
from .commands 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
|