This commit is contained in:
Voussoir 2015-06-30 19:25:55 -07:00
parent 9d64311ead
commit 006788c40e
2 changed files with 11 additions and 8 deletions

View file

@ -1,7 +1,7 @@
Passwordy Passwordy
====== ======
Generate randomized strings, useful for generating passwords and such. Generates randomized strings, useful for making passwords and such.
--------------------------------------------------------------- ---------------------------------------------------------------
|Generates a randomized password. | |Generates a randomized password. |

View file

@ -66,9 +66,9 @@ def make_sentence(length=None, joiner=' '):
if __name__ == '__main__': if __name__ == '__main__':
args = sys.argv args = sys.argv
argc = len(args) argc = len(args) - 1
if argc == 1: if argc == 0:
mode = 'password' mode = 'password'
length = DEFAULT_LENGTH length = DEFAULT_LENGTH
@ -76,27 +76,30 @@ if __name__ == '__main__':
mode = 'password' mode = 'password'
length = int(args[1]) length = int(args[1])
elif 'sent' in args[1].lower() and argc == 2: elif 'sent' in args[1].lower() and argc == 1:
mode = 'sentence' mode = 'sentence'
length = DEFAULT_SENTENCE length = DEFAULT_SENTENCE
elif argc == 2: elif argc == 1:
mode = None mode = None
print(HELP_MESSAGE) print(HELP_MESSAGE)
print(HELP_SENTENCE) print(HELP_SENTENCE)
elif args[2].isdigit(): elif 'sent' in args[1].lower() and args[2].isdigit():
mode = 'sentence' mode = 'sentence'
length = int(args[2]) length = int(args[2])
elif 'sent' in args[1].lower():
mode = 'sentence'
length = DEFAULT_SENTENCE
if mode == 'password': if mode == 'password':
punc = 'p' in args punc = 'p' in args
digi = 'd' in args digi = 'd' in args
print(make_password(length, punc, digi)) print(make_password(length, punc, digi))
elif mode == 'sentence': elif mode == 'sentence':
if argc == 4: if argc == 3:
joiner = args[3] joiner = args[3]
else: else:
joiner = ' ' joiner = ' '