def command_run(self, name, args):
        if name not in self.commands:
            matches = []
            for state in xrange(0, len(self.commands)):
                match = self.complete(name, state)
                if match is None:
                    break
                else:
                    matches.append(match)

            # One possible match, complete it
            if len(matches) == 1:
                return self.command_run(matches[0], args)

            return False

        if not self.commands[name].valid_in_context(self.context):
            print 'Not valid in context'
            return False

        try:
            self.commands[name].run(*args)
        except TypeError, e:
            msg = e.message
            info = RE_RUN_GIVEN.search(e.message)
            if info:
                # Function arguments count (minus self)
                args = self.commands[name].run.func_code.co_argcount - 1
                try:
                    least = args - len(self.commands[name].run.func_defaults)
                except TypeError:
                    least = 0
                # Given arguments count (minus self)
                given = int(info.groupdict()['given']) - 1
                if args == least:
                    error = 'exactly'
                    count = args
                elif given < least:
                    error = 'at least'
                    count = least
                elif given > args:
                    error = 'at most'
                    count = args
                else:
                    print 'huh?', args, least, given
                    return

                plural = ''
                if count != 1:
                    plural = 's'
                self.error('Syntax error: %s takes %s %d argument%s (%d given)' % \
                    (name, error, count, plural, given))
                return True
            else:
                print dir(e)
                print e.message
                print e.args
                raise

        return True
dataset/ETHPy150Open tehmaze/nagios-cli/nagios_cli/cli.py/CLI.command_run/original