Add --quiet option, only output the generated passwords.
This commit is contained in:
parent
6795454af1
commit
4596fc38ee
11
bin/pwgen
11
bin/pwgen
@ -10,6 +10,10 @@ default_config_file=os.path.expanduser('~/.pwgen.cfg')
|
||||
def main():
|
||||
|
||||
parser = argparse.ArgumentParser(description='Generate passwords')
|
||||
parser.add_argument(
|
||||
'--quiet', '-q',
|
||||
action='store_true',
|
||||
help='Only echo the generated passwords.')
|
||||
parser.add_argument(
|
||||
'--generate-config', '-g',
|
||||
action='store_true',
|
||||
@ -82,6 +86,9 @@ def main():
|
||||
|
||||
args = vars(parser.parse_args())
|
||||
|
||||
quiet = args['quiet']
|
||||
del args['quiet']
|
||||
|
||||
config_file = args['config_file']
|
||||
del args['config_file']
|
||||
|
||||
@ -103,6 +110,10 @@ def main():
|
||||
|
||||
pwds, seen_entropy = pwgen.generate_passwords(conf)
|
||||
|
||||
if (quiet):
|
||||
for pw in pwds.keys():
|
||||
print(pw)
|
||||
else:
|
||||
print("Generated {} passwords".format(len(pwds)))
|
||||
if seen_entropy:
|
||||
print("Full-knowledge entropy is {0:.2g}".format(seen_entropy))
|
||||
|
Loading…
Reference in New Issue
Block a user