diff --git a/diceware.py b/diceware.py index 72c9eca6a326739cfab13b59ef16aac4dd975814..0d9a503ba1c16e05f4623ce1c12a69b90bee9ca8 100644 --- a/diceware.py +++ b/diceware.py @@ -40,6 +40,10 @@ def handle_options(args): type=argparse.FileType('r'), help="Input wordlist. `-' will read from stdin.", ) + parser.add_argument( + '--version', action='store_true', + help='output version information and exit.', + ) parser.set_defaults(capitalize=True) args = parser.parse_args(args) return args diff --git a/tests/test_diceware.py b/tests/test_diceware.py index 9cf2e3f2bcdfda95767d43ec54fae891a147428b..e63264f9a307f9520a4b7c39fc6f35e0bb04748d 100644 --- a/tests/test_diceware.py +++ b/tests/test_diceware.py @@ -157,6 +157,7 @@ class TestDicewareModule(object): assert options.capitalize is True assert options.specials == 0 assert options.infile is None + assert options.version is False def test_handle_options_infile(self, tmpdir): # we can give an infile @@ -167,6 +168,11 @@ class TestDicewareModule(object): assert options.infile is not None assert options.infile.read() == 'one\ntwo\n' + def test_handle_options_version(self): + # we can ask for version infos + options = handle_options(['--version', ]) + assert options.version is True + def test_main(self, capsys): # we can get a passphrase main([]) # call with default options in place