Create a CommandLineInterface, feed it with the given user input and return the CLI object. This returns a (result, CLI) tuple. note: this only works if you import your prompt and then this function!!
(type, message, text, **kwargs)
| 54 | |
| 55 | |
| 56 | def feed_app_with_input(type, message, text, **kwargs): |
| 57 | """ |
| 58 | Create a CommandLineInterface, feed it with the given user input and return |
| 59 | the CLI object. |
| 60 | |
| 61 | This returns a (result, CLI) tuple. |
| 62 | note: this only works if you import your prompt and then this function!! |
| 63 | """ |
| 64 | # If the given text doesn't end with a newline, the interface won't finish. |
| 65 | assert text.endswith('\n') |
| 66 | |
| 67 | application = getattr(prompts, type).question(message, **kwargs) |
| 68 | |
| 69 | loop = PosixEventLoop() |
| 70 | try: |
| 71 | inp = PipeInput() |
| 72 | inp.send_text(text) |
| 73 | cli = CommandLineInterface( |
| 74 | application=application, |
| 75 | eventloop=loop, |
| 76 | input=inp, |
| 77 | output=DummyOutput()) |
| 78 | result = cli.run() |
| 79 | return result, cli |
| 80 | finally: |
| 81 | loop.close() |
| 82 | inp.close() |
| 83 | |
| 84 | |
| 85 | def remove_ansi_escape_sequences(text): |
no outgoing calls
searching dependent graphs…