diff --git a/main.hs b/main.hs index a876e5d..a0a567f 100644 --- a/main.hs +++ b/main.hs @@ -5,6 +5,8 @@ import System.Console.CmdArgs import System.Environment (getArgs, withArgs) import Control.Monad (when) +import Paths_alea (getDataFileName) + import Diceware import Random @@ -46,8 +48,9 @@ main = do exec :: Args -> IO () exec opts@Args{..} = do - file <- readFile dictionary' opts <- getProgArgs + defaultDict <- getDataFileName "diceware" + file <- readFile (if null dictionary then defaultDict else dictionary) if interactive then interact (unlines . map (dice file) . lines) else do @@ -60,4 +63,3 @@ exec opts@Args{..} = do dice' x n = readDiceware' (parseDiceware x) n -- default arguments phraseLength' = if phraseLength == 0 then 6 else phraseLength - dictionary' = if null dictionary then "diceware" else dictionary