diff --git a/diceware/diceware.py b/diceware/diceware.py index 384084647f195c693901aefae832d8079d2348cd..57daa2f0c795b38805a13fef3dceb2c710faf344 100644 --- a/diceware/diceware.py +++ b/diceware/diceware.py @@ -1,6 +1,7 @@ import argparse import os import re +import sys from random import SystemRandom @@ -69,5 +70,7 @@ def get_passphrase(wordnum=6, specials=True, separator='', lang='en', return result -def main(): - pass +def main(args=1): + if args is 1: + args = sys.argv[1:] + options = handle_options(args) diff --git a/tests/test_diceware.py b/tests/test_diceware.py index 2bcea2ccc8c289c8a2b167c27c387d1293663cd9..e094d0592a7415bd8bf7b081774f7c24c66c7440 100644 --- a/tests/test_diceware.py +++ b/tests/test_diceware.py @@ -3,6 +3,7 @@ import pytest import sys from diceware.diceware import ( SRC_DIR, get_wordlist, get_wordlist_path, get_passphrase, handle_options, + main, ) @@ -55,11 +56,17 @@ class TestDicewareModule(object): r2 = get_passphrase() assert r1 != r2 - def test_handle_options(self, capsys): + def test_handle_options(self): # we can get help with pytest.raises(SystemExit) as exc_info: handle_options(['--help']) assert exc_info.value.code == 0 + + def test_main(self, capsys): + # we can get help + with pytest.raises(SystemExit) as exc_info: + main(['diceware', '--help']) + assert exc_info.value.code == 0 out, err = capsys.readouterr() out = out.replace( os.path.basename(sys.argv[0]), 'diceware')