aboutsummaryrefslogtreecommitdiffstats
path: root/pet_names
diff options
context:
space:
mode:
authorGravatar Daniel Washburn <daniel@washburn.at> 2021-02-21 11:52:45 -0500
committerGravatar Daniel Washburn <daniel@washburn.at> 2021-02-21 11:52:45 -0500
commit623352cdd7f83271dc235dd5073bdfdaafc573fa (patch)
treee261e1c6deb85f501b614c8533d6f1140fabf16f /pet_names
parent644bf682b90b67773f54163509d6962eebf3daea (diff)
Add ability to specify the number of words in each pet name
Diffstat (limited to 'pet_names')
-rwxr-xr-xpet_names14
1 files changed, 9 insertions, 5 deletions
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__":