Add --prefix, --suffix.
This commit is contained in:
parent
8d258241e7
commit
3a5235c636
1 changed files with 14 additions and 1 deletions
|
@ -18,7 +18,6 @@ length:
|
||||||
# Sentence mode:
|
# Sentence mode:
|
||||||
--sentence:
|
--sentence:
|
||||||
If this argument is passed, `length` random words are chosen.
|
If this argument is passed, `length` random words are chosen.
|
||||||
Only --separator, --upper, and --lower can be used in sentence mode.
|
|
||||||
|
|
||||||
--separator <string>:
|
--separator <string>:
|
||||||
When using sentence mode, the words will be joined with this string.
|
When using sentence mode, the words will be joined with this string.
|
||||||
|
@ -40,11 +39,18 @@ length:
|
||||||
--punctuation
|
--punctuation
|
||||||
Include punctuation symbols in the password.
|
Include punctuation symbols in the password.
|
||||||
|
|
||||||
|
# Both modes:
|
||||||
--upper
|
--upper
|
||||||
Convert the entire password to uppercase.
|
Convert the entire password to uppercase.
|
||||||
|
|
||||||
--lower
|
--lower
|
||||||
Convert the entire password to lowercase.
|
Convert the entire password to lowercase.
|
||||||
|
|
||||||
|
--prefix X:
|
||||||
|
Add a static prefix to the password.
|
||||||
|
|
||||||
|
--suffix X:
|
||||||
|
Add a static suffix to the password.
|
||||||
'''
|
'''
|
||||||
import argparse
|
import argparse
|
||||||
import math
|
import math
|
||||||
|
@ -134,6 +140,11 @@ def passwordy_argparse(args):
|
||||||
password = password.lower()
|
password = password.lower()
|
||||||
elif args.upper:
|
elif args.upper:
|
||||||
password = password.upper()
|
password = password.upper()
|
||||||
|
|
||||||
|
prefix = args.prefix or ''
|
||||||
|
suffix = args.suffix or ''
|
||||||
|
password = f'{prefix}{password}{suffix}'
|
||||||
|
|
||||||
pipeable.stdout(password)
|
pipeable.stdout(password)
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
@ -150,6 +161,8 @@ def main(argv):
|
||||||
parser.add_argument('--punctuation', action='store_true')
|
parser.add_argument('--punctuation', action='store_true')
|
||||||
parser.add_argument('--lower', action='store_true')
|
parser.add_argument('--lower', action='store_true')
|
||||||
parser.add_argument('--upper', action='store_true')
|
parser.add_argument('--upper', action='store_true')
|
||||||
|
parser.add_argument('--prefix', default=None)
|
||||||
|
parser.add_argument('--suffix', default=None)
|
||||||
parser.set_defaults(func=passwordy_argparse)
|
parser.set_defaults(func=passwordy_argparse)
|
||||||
|
|
||||||
return betterhelp.single_main(argv, parser, __doc__)
|
return betterhelp.single_main(argv, parser, __doc__)
|
||||||
|
|
Loading…
Reference in a new issue