Last active
November 24, 2019 00:48
-
-
Save a358003542/6e6c0a654a9b2d4ae92d141161dbf767 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import click | |
import random | |
def random_choice(input): | |
line = random.choice(open(input, encoding='utf8').readlines()) | |
if line: | |
return line | |
else: | |
return random_choice(input) | |
@click.command() | |
@click.argument('input', type=click.Path(exists=True)) | |
def main(input): | |
line = random_choice(input) | |
click.echo(line) | |
click.pause() | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment