from .commands import commands def display_help(extra_args): """ Display help dialogues for each command """ 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): """ Runs a given command with the provided args Alsso automatically maps the given command string to the correct Command class """ 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.func(args)