Use portable static path

This commit is contained in:
Rnhmjoj 2014-10-14 00:40:42 +02:00
parent c4b13e87e7
commit 6e286041f6

View File

@ -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