示例#1
0
def start_undoable_rl(interpreter, interparg):
    for command, predicate in interps.interpreters:
        if predicate(interpreter):
            return run_with_listeners(command + interparg)
    else:
        modify_env_with_modified_rl()
        run_with_listeners(interpreter + interparg)
示例#2
0
def start_undoable_rl(interpreter, interparg):
    """Run an interpreter either with an undo script or with a generic method.

    If an interpreter matches the first argument, run script like that.
    Otherwise run that command in an environment where a modified readline will
    be used instead of the standard one."""
    for command, predicate in interps.interpreters:
        if predicate(interpreter):
            return run_with_listeners(command + interparg)
    else:
        modify_env_with_modified_rl()
        return run_with_listeners([interpreter] + interparg)
示例#3
0
import argparse

from rlundo.termrewrite import run_with_listeners

if __name__ == '__main__':
    parser = argparse.ArgumentParser(
        description=
        "Run a command in a pty, saving and restoring the terminal state")
    parser.add_argument('--save-addr', action='store', default=None)
    parser.add_argument('--restore-addr', action='store', default=None)
    parser.add_argument('command', nargs='*')
    args = parser.parse_args()
    if args.command == []:
        args.command = [
            'python', '-c',
            "while True: (raw_input if '' == b'' else input)('>')"
        ]
    run_with_listeners(args.command,
                       save_addr=args.save_addr,
                       restore_addr=args.restore_addr)
示例#4
0
import argparse

from rlundo.termrewrite import run_with_listeners

if __name__ == '__main__':
    parser = argparse.ArgumentParser(description="Run a command in a pty, saving and restoring the terminal state")
    parser.add_argument('--save-addr', action='store', default=None)
    parser.add_argument('--restore-addr', action='store', default=None)
    parser.add_argument('command', nargs='*')
    args = parser.parse_args()
    if args.command == []:
        args.command = ['python', '-c', "while True: (raw_input if '' == b'' else input)('>')"]
    run_with_listeners(args.command, save_addr=args.save_addr, restore_addr=args.restore_addr)