diff options
| author | 2021-02-21 11:52:45 -0500 | |
|---|---|---|
| committer | 2021-02-21 11:52:45 -0500 | |
| commit | 623352cdd7f83271dc235dd5073bdfdaafc573fa (patch) | |
| tree | e261e1c6deb85f501b614c8533d6f1140fabf16f | |
| parent | 644bf682b90b67773f54163509d6962eebf3daea (diff) | |
Add ability to specify the number of words in each pet name
| -rw-r--r-- | README.md | 13 | ||||
| -rwxr-xr-x | pet_names | 14 |
2 files changed, 15 insertions, 12 deletions
@@ -1,6 +1,6 @@ # Random Pet Name Generator -This tool uses the [PGP Biometric word list](https://en.wikipedia.org/wiki/PGP_word_list) to generate random two-word pet names, a la Docker friendly names. +This tool uses the [PGP Biometric word list](https://en.wikipedia.org/wiki/PGP_word_list) to generate random n-word pet names, a la Docker friendly names. ## Installation @@ -9,13 +9,12 @@ This tool uses the [PGP Biometric word list](https://en.wikipedia.org/wiki/PGP_w ## Usage - ./pet_names [n] + ./pet_names [m] [n] - Generate n random pet names. If no value is supplied, the tool defaults to generating a single pet name. + Generate m random pet names, n words in length. If no value is supplied, the tool defaults to generating one two-word pet name. ## Example - ./pet_names 3 - burbank_provincial - retouch_therapist - slowdown_millionaire + ./pet_names 2 3 + talon_publisher_scenic + trauma_ohio_zulu @@ -1,6 +1,6 @@ #!/usr/bin/env python3 # SPDX-License-Identifier: CDDL-1.0 -# Copyright (c) 2020 Daniel Washburn <daniel@washburn.at> +# Copyright (c) 2020, 2021 Daniel Washburn <daniel@washburn.at> from hex2words import hex2words from secrets import token_hex @@ -8,12 +8,16 @@ import sys def main(argv): try: - num = int(argv[1]) + names = int(argv[1]) except: - num = 1 + names = 1 + try: + nbytes = int(argv[2]) + except: + nbytes = 2 - for i in range(num): - tok = token_hex(2) + for i in range(names): + tok = token_hex(nbytes) print("_".join(hex2words.hex2words(tok).lower().split())) if __name__ == "__main__": |