play/wordpw

21 lines
451 B
Plaintext
Raw Normal View History

2018-08-23 12:21:44 +00:00
#!/usr/bin/env python3
import sys
import os
import secrets
prefix = os.getenv('HOME') + '/.local/share/words/'
if len(sys.argv) == 2:
ct = int(sys.argv[1])
2018-08-23 12:24:36 +00:00
wl = 'default'
2018-08-23 12:21:44 +00:00
elif len(sys.argv) == 3:
ct = int(sys.argv[1])
wl = sys.argv[2]
else:
2018-08-23 12:24:36 +00:00
print(f'Usage: {sys.argv[0]} nwords [wordlist]')
2018-08-23 12:21:44 +00:00
exit(1)
words = [word.strip() for word in open(prefix + wl).readlines()]
print(' '.join([secrets.choice(words) for _ in range(ct)]))