Add count option, logic, and documentation.
authorKim Slawson <redacted>
Sun, 3 Mar 2013 05:05:50 +0000 (00:05 -0500)
committerKim Slawson <redacted>
Sun, 3 Mar 2013 05:05:50 +0000 (00:05 -0500)
README.mkd
xkcd-password.py

index 346801c948477f9e208bdf4a1c5b7c044ce70a5d..2142f88b9aa2e721277f638f824227cfd73f9e3e 100644 (file)
@@ -25,3 +25,6 @@ xkcd-password.py [options]
 * `-V, --verbose` Report various metrics for given options
 
 * `-a ACROSTIC, --acrostic=ACROSTIC` Constrain word choices to those starting with the letters in a given word  
+
+* `-c COUNT, --count=COUNT` Number of passwords to generate
+
index b2190ed5c619261e74b639da6e21e992d207244d..4427cb0645089412776aaf7bdd2fb450f93a29b8 100755 (executable)
@@ -213,6 +213,7 @@ def generate_xkcdpassword(wordlist, n_words=4, interactive=False, acrostic=False
 
 if __name__ == '__main__':
 
+    count = 1
     usage = "usage: %prog [options]"
     parser = optparse.OptionParser(usage)
 
@@ -240,6 +241,9 @@ if __name__ == '__main__':
     parser.add_option("-a", "--acrostic", dest="acrostic",
                       default=False,
                       help="Acrostic to constrain word choices")
+    parser.add_option("-c", "--count", dest="count",
+                      default=1, type="int",
+                      help="number of passwords to generate")
     (options, args) = parser.parse_args()
     validate_options(options, args)
 
@@ -251,5 +255,8 @@ if __name__ == '__main__':
     if options.verbose:
         verbose_reports(len(my_wordlist), options)
 
-    print(generate_xkcdpassword(my_wordlist, interactive=options.interactive,
-                                n_words=options.numwords, acrostic=options.acrostic))
+    count = options.count
+    while count > 0:
+        print(generate_xkcdpassword(my_wordlist, interactive=options.interactive,
+                                    n_words=options.numwords, acrostic=options.acrostic))
+        count -= 1
git clone https://git.99rst.org/PROJECT