from lib.exceptions import CmdNotFoundException class Command: def __init__(self): pass def execute(self, loader, params): pass def usage(self, cmd_name): return cmd_name class AdminCommand(Command): pass class NetworkCommand(Command): pass class DomainCommand(Command): pass class CommandManager: def __init__(self): self.cmds = { 'admin' : AdminCommand(), 'network': NetworkCommand(), 'domain' : DomainCommand(), } def find(self, cmd): if cmd in self.cmds: return self.cmds[cmd] else: raise CmdNotFoundException(cmd + 'is not a valid command.') def commands(self): return self.cmds.keys()