Solve huge bug

I should use tests someday.
This commit is contained in:
Rnhmjoj 2014-10-17 00:01:16 +02:00
parent 44123e1443
commit 2abb1c9074

13
main.hs
View File

@ -9,7 +9,7 @@ import Alea.Diceware
import Alea.Random
_NAME = "Alea"
_VERSION = "0.2.0"
_VERSION = "0.2.1"
_INFO = _NAME ++ " version " ++ _VERSION
_ABOUT = "a diceware passphrase generator"
_COPYRIGHT = "(C) Michele Guerini Rocco 2014"
@ -44,12 +44,11 @@ main = getProgArgs >>= defaults >>= exec
-- Assign default values to unspecified args
defaults :: Args -> IO Args
defaults args@Args{..} = do
defaultDict <- getDataFileName "dict/diceware" >>= readFile
dict <- readFile dictionary
return args
{ dictionary = if null dict then defaultDict else dict
, phraseLength = if phraseLength == 0 then 6 else phraseLength
}
dictionary' <- if null dictionary
then getDataFileName "dict/diceware" >>= readFile
else readFile dictionary
let phraseLength' = if phraseLength == 0 then 6 else phraseLength
return args { dictionary = dictionary', phraseLength = phraseLength'}
-- Main function
exec :: Args -> IO ()