예제 #1
0
def main():
    history = InMemoryHistory()
    manager = CommandManager()

    while True:
        try:
            input = prompt('>>> ', lexer=GrepLexer,
                           completer=grep_completer,
                           style=DocumentStyle,
                           history=history,
                           display_completions_in_columns=True)

            if not input \
                    or input.lower() == 'quit'\
                    or input.lower() == 'exit':
                print 'See you.'
                break
            elif os.path.exists(input):
                manager.setpath(input)
            else:
                func, args = input.split()[0].lower(), \
                             input.split()[1:]
                try:
                    getattr(manager, func)(args)
                except AttributeError as error:
                    print 'No function: %s' % func

        except KeyboardInterrupt as stop:
            print 'See you.'
            break
예제 #2
0
def main():
    history = InMemoryHistory()
    manager = CommandManager()

    while True:
        try:
            input = prompt('>>> ',
                           lexer=GrepLexer,
                           completer=grep_completer,
                           style=DocumentStyle,
                           history=history,
                           display_completions_in_columns=True)

            if not input \
                    or input.lower() == 'quit'\
                    or input.lower() == 'exit':
                print 'See you.'
                break
            elif os.path.exists(input):
                manager.setpath(input)
            else:
                func, args = input.split()[0].lower(), \
                             input.split()[1:]
                try:
                    getattr(manager, func)(args)
                except AttributeError as error:
                    print 'No function: %s' % func

        except KeyboardInterrupt as stop:
            print 'See you.'
            break