Пример #1
0
    def __call__(self, func):
        try:
            if func.__name__ == DEFAULT:
                self.message[0] = "%sDefault%s: %s" % (terminal.underline(), terminal.reset(), self.message[0])
        except:
            pass

        func._command_help = self.message

        return func
Пример #2
0
    def __call__(self, func):
        try:
            if func.__name__ == DEFAULT:
                self.message[0] = "%sDefault%s: %s" % (
                    terminal.underline(), terminal.reset(), self.message[0])
        except:
            pass

        func._command_help = self.message

        return func
Пример #3
0
    def executeHelp(self, line, indent=0):
        self._init()

        method = self._findMethod(line)
        if method:
            try:
                try:
                    method_name = method.__name__
                except:
                    #method_name = method.__class__.__name__
                    method_name = None

                if method_name == DEFAULT: # Print controller help
                    CommandHelp.display(self, indent=indent)
                    if self.modifiers:
                        CommandHelp.printText(
                            "%sModifiers%s: %s"%(terminal.underline()
                                                 , terminal.reset()
                                                 , ", ".join(
                                                     sorted(self.modifiers)))
                            , indent=indent)
                    if CommandHelp.hasHelp(method):
                        CommandHelp.display(method, indent=indent)

                    indent += 2
                    for command in sorted(self.commands.keys()):
                        CommandHelp.printText("- %s%s%s:"%(terminal.bold()
                                                           , command
                                                           , terminal.reset())
                                              , indent=indent-1)
                        self.executeHelp([command], indent=indent)
                    return
                elif isinstance(method, ShellException):
                    # Method not implemented
                    pass
                elif method_name is None: # Nothing to print yet
                    method.executeHelp(line, indent=indent)
                else: # Print help for a command
                    CommandHelp.display(method, indent=indent)
                    return
            except IOError as e: 
                raise ShellException(str(e))
        else:
            raise ShellException(
                "Method was not set? %s"%(line))
Пример #4
0
    def executeHelp(self, line, indent=0):
        self._init()

        method = self._findMethod(line)
        if method:
            try:
                try:
                    method_name = method.__name__
                except:
                    #method_name = method.__class__.__name__
                    method_name = None

                if method_name == DEFAULT:  # Print controller help
                    CommandHelp.display(self, indent=indent)
                    if self.modifiers:
                        CommandHelp.printText(
                            "%sModifiers%s: %s" %
                            (terminal.underline(), terminal.reset(), ", ".join(
                                sorted(self.modifiers))),
                            indent=indent)
                    if CommandHelp.hasHelp(method):
                        CommandHelp.display(method, indent=indent)

                    indent += 2
                    for command in sorted(self.commands.keys()):
                        CommandHelp.printText(
                            "- %s%s%s:" %
                            (terminal.bold(), command, terminal.reset()),
                            indent=indent - 1)
                        self.executeHelp([command], indent=indent)
                    return
                elif isinstance(method, ShellException):
                    # Method not implemented
                    pass
                elif method_name is None:  # Nothing to print yet
                    method.executeHelp(line, indent=indent)
                else:  # Print help for a command
                    CommandHelp.display(method, indent=indent)
                    return
            except IOError as e:
                raise ShellException(str(e))
        else:
            raise ShellException("Method was not set? %s" % (line))