dockge-cli/dockge_cli/client/run.py
Firq d3e5d4ae56
All checks were successful
/ backend-pylint (push) Successful in 13s
/ build-artifacts (push) Successful in 8s
/ publish-artifacts (push) Successful in 20s
Improved typing, refactored code, fixed some issues
2024-07-04 22:12:36 +02:00

29 lines
792 B
Python

from .commandprovider.factory import commands
def display_help(extra_args):
if not extra_args:
print(f"{commands['help'].description}")
return
if len(extra_args) > 1:
raise ValueError("Invalid arguments for help command")
if extra_args[0] not in commands:
raise ValueError("Unknown command")
print(f"{commands[extra_args[0]].description}")
def run(command, args):
if command not in commands:
raise ValueError("Invalid Command")
c = commands[command]
if args and c.args > len(args):
raise ValueError("Too many arguments")
if args and c.args < len(args) and not c.optional:
raise ValueError("Missing arguments")
if command == "help":
display_help(args)
return
c.binding(args)