From 72a8607d01f0185961291f300484a84572349e33 Mon Sep 17 00:00:00 2001 From: ulif <uli@gnufix.de> Date: Sat, 1 Aug 2015 03:07:28 +0200 Subject: [PATCH] Enable the -w option. --- diceware/__init__.py | 10 +++++++++- tests/exp_help_output.txt | 6 +++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/diceware/__init__.py b/diceware/__init__.py index 8203ad4..0e3a1bb 100644 --- a/diceware/__init__.py +++ b/diceware/__init__.py @@ -20,7 +20,7 @@ import pkg_resources import sys from random import SystemRandom from diceware.wordlist import ( - WordList, get_wordlist_path, WORDLISTS_DIR, + WordList, get_wordlist_path, WORDLISTS_DIR, get_wordlist_names, ) __version__ = pkg_resources.get_distribution('diceware').version @@ -80,6 +80,7 @@ def handle_options(args): """Handle commandline options. """ random_sources = get_random_sources().keys() + wordlist_names = get_wordlist_names() parser = argparse.ArgumentParser( description="Create a passphrase", epilog="Wordlists are stored in %s" % WORDLISTS_DIR @@ -106,6 +107,13 @@ def handle_options(args): help=( "Get randomness from this source. Possible values: `%s'. " "Default: system" % "', `".join(sorted(random_sources)))) + parser.add_argument( + '-w', '--wordlist', default='en_8k', choices=wordlist_names, + metavar="NAME", + help=( + "Use words from this wordlist. Possible values: `%s'. " + "Wordlists are stored in the folder displayed below. " + "Default: en_8k" % "', `".join(wordlist_names))) parser.add_argument( 'infile', nargs='?', metavar='INFILE', default=None, type=argparse.FileType('r'), diff --git a/tests/exp_help_output.txt b/tests/exp_help_output.txt index 2bd85d0..dadef71 100644 --- a/tests/exp_help_output.txt +++ b/tests/exp_help_output.txt @@ -1,5 +1,5 @@ usage: diceware [-h] [-n NUM] [-c | --no-caps] [-s NUM] [-d DELIMITER] - [-r SOURCE] [--version] + [-r SOURCE] [-w NAME] [--version] [INFILE] Create a passphrase @@ -19,6 +19,10 @@ optional arguments: -r SOURCE, --randomsource SOURCE Get randomness from this source. Possible values: `realdice', `system'. Default: system + -w NAME, --wordlist NAME + Use words from this wordlist. Possible values: + `en_8k', `en_orig'. Wordlists are stored in the folder + displayed below. Default: en_8k --version output version information and exit. Wordlists are stored in <WORDLISTS-DIR> -- GitLab