From 6fe18e9b913010d425d1bf3d4dca787129d89bff Mon Sep 17 00:00:00 2001
From: ulif <uli@gnufix.de>
Date: Wed, 28 Jan 2015 10:25:46 +0100
Subject: [PATCH] Use opts in main().

---
 diceware/diceware.py   | 7 +++++--
 tests/test_diceware.py | 9 ++++++++-
 2 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/diceware/diceware.py b/diceware/diceware.py
index 3840846..57daa2f 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 2bcea2c..e094d05 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')
-- 
GitLab