2024-06-29 15:41:09 +00:00
|
|
|
import argparse
|
|
|
|
import sys
|
|
|
|
|
|
|
|
from .. import __version__
|
2024-07-05 09:15:07 +00:00
|
|
|
from ..models import Arguments
|
2024-07-04 20:12:36 +00:00
|
|
|
from .commandprovider.factory import commands
|
2024-06-29 15:41:09 +00:00
|
|
|
|
2024-07-03 18:36:22 +00:00
|
|
|
def parse_arguments():
|
2024-07-05 14:05:35 +00:00
|
|
|
"""
|
|
|
|
Create a parser and parse the arguments of sys.argv based on the Arguments Namespace
|
|
|
|
Returns arguments and extra arguments separately
|
|
|
|
"""
|
2024-07-03 18:36:22 +00:00
|
|
|
parser = argparse.ArgumentParser(
|
|
|
|
prog="dockge_cli",
|
|
|
|
description="CLI interface for interacting with Dockge",)
|
2024-06-29 15:41:09 +00:00
|
|
|
|
2024-07-04 20:12:36 +00:00
|
|
|
parser.add_argument("command", choices=list(commands.keys()), action="store", type=str, default=None)
|
2024-07-03 18:36:22 +00:00
|
|
|
parser.add_argument("--version", action="version", version=f"dockge_cli {__version__}")
|
2024-07-02 16:09:56 +00:00
|
|
|
|
2024-07-03 18:36:22 +00:00
|
|
|
args = Arguments()
|
|
|
|
args, extra_args = parser.parse_known_args(sys.argv[1:], namespace=args)
|
|
|
|
return args, extra_args
|