Add --count option.
This commit is contained in:
parent
355c02cf7e
commit
3ddaa83edd
1 changed files with 37 additions and 28 deletions
|
@ -75,38 +75,39 @@ def random_hex(length):
|
||||||
return token
|
return token
|
||||||
|
|
||||||
def passwordy_argparse(args):
|
def passwordy_argparse(args):
|
||||||
if args.sentence:
|
for index in range(args.count):
|
||||||
password = make_sentence(args.length, args.separator)
|
if args.sentence:
|
||||||
else:
|
password = make_sentence(args.length, args.separator)
|
||||||
if not any([args.letters, args.digits, args.hex, args.binary, args.punctuation]):
|
|
||||||
letters = True
|
|
||||||
digits = True
|
|
||||||
else:
|
else:
|
||||||
letters = args.letters
|
if not any([args.letters, args.digits, args.hex, args.binary, args.punctuation]):
|
||||||
digits = args.digits
|
letters = True
|
||||||
password = make_password(
|
digits = True
|
||||||
args.length,
|
else:
|
||||||
binary=args.binary,
|
letters = args.letters
|
||||||
digits=digits,
|
digits = args.digits
|
||||||
hex=args.hex,
|
password = make_password(
|
||||||
letters=letters,
|
args.length,
|
||||||
punctuation=args.punctuation,
|
binary=args.binary,
|
||||||
)
|
digits=digits,
|
||||||
if args.lower:
|
hex=args.hex,
|
||||||
password = password.lower()
|
letters=letters,
|
||||||
elif args.upper:
|
punctuation=args.punctuation,
|
||||||
password = password.upper()
|
)
|
||||||
|
if args.lower:
|
||||||
|
password = password.lower()
|
||||||
|
elif args.upper:
|
||||||
|
password = password.upper()
|
||||||
|
|
||||||
if args.groups_of is not None:
|
if args.groups_of is not None:
|
||||||
chunks = gentools.chunk_generator(password, args.groups_of)
|
chunks = gentools.chunk_generator(password, args.groups_of)
|
||||||
chunks = (''.join(chunk) for chunk in chunks)
|
chunks = (''.join(chunk) for chunk in chunks)
|
||||||
password = args.separator.join(chunks)
|
password = args.separator.join(chunks)
|
||||||
|
|
||||||
prefix = args.prefix or ''
|
prefix = args.prefix or ''
|
||||||
suffix = args.suffix or ''
|
suffix = args.suffix or ''
|
||||||
password = f'{prefix}{password}{suffix}'
|
password = f'{prefix}{password}{suffix}'
|
||||||
|
|
||||||
pipeable.stdout(password)
|
pipeable.stdout(password)
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
def main(argv):
|
def main(argv):
|
||||||
|
@ -155,6 +156,14 @@ def main(argv):
|
||||||
In normal mode, the --groups-of chunks will be joined with this string.
|
In normal mode, the --groups-of chunks will be joined with this string.
|
||||||
''',
|
''',
|
||||||
)
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
'--count',
|
||||||
|
type=int,
|
||||||
|
default=1,
|
||||||
|
help='''
|
||||||
|
Generate this many passwords, to be printed out one per line.
|
||||||
|
''',
|
||||||
|
)
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
'--letters',
|
'--letters',
|
||||||
action='store_true',
|
action='store_true',
|
||||||
|
|
Loading…
Reference in a new issue