Interface to input(...) to enable unit test mocks to be created
| 356 | |
| 357 | |
| 358 | class CommandInput(object): |
| 359 | """ |
| 360 | Interface to input(...) to enable unit test mocks to be created |
| 361 | """ |
| 362 | |
| 363 | def fail(self, msg): |
| 364 | raise Exception(msg) |
| 365 | |
| 366 | def prompt(self, prompt): |
| 367 | return input(prompt) |
| 368 | |
| 369 | def getpass(self, prompt): |
| 370 | return getpass.getpass(prompt) |
| 371 | |
| 372 | def continue_maybe(self, prompt): |
| 373 | while True: |
| 374 | result = input("\n%s (y/n): " % prompt) |
| 375 | if result.lower() == "y": |
| 376 | return |
| 377 | elif result.lower() == "n": |
| 378 | self.fail("Okay, exiting") |
| 379 | else: |
| 380 | prompt = "Please input 'y' or 'n'" |
| 381 | |
| 382 | |
| 383 | class PullRequest(object): |