From 196f32828ffbbc2964118b3a659d9572bab82b62 Mon Sep 17 00:00:00 2001 From: ulif <uli@gnufix.de> Date: Fri, 27 Mar 2015 11:23:14 +0100 Subject: [PATCH] Add --version option in option handler. --- diceware.py | 4 ++++ tests/test_diceware.py | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/diceware.py b/diceware.py index 72c9eca..0d9a503 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 9cf2e3f..e63264f 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 -- GitLab