aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--README.md13
-rwxr-xr-xpet_names14
2 files changed, 15 insertions, 12 deletions
diff --git a/README.md b/README.md
index 88258d8..29d3ddd 100644
--- a/README.md
+++ b/README.md
@@ -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
diff --git a/pet_names b/pet_names
index 6dbb5c6..e91fe1d 100755
--- a/pet_names
+++ b/pet_names
@@ -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__":