Dictionary specified path was ignored.
Change to length since Diceware is a List
This commit is contained in:
Rnhmjoj 2014-10-16 23:21:03 +02:00
parent 6b28ba7258
commit 699736be55

12
main.hs
View File

@ -9,7 +9,7 @@ import Alea.Diceware
import Alea.Random
_NAME = "Alea"
_VERSION = "0.1.0"
_VERSION = "0.2.0"
_INFO = _NAME ++ " version " ++ _VERSION
_ABOUT = "a diceware passphrase generator"
_COPYRIGHT = "(C) Michele Guerini Rocco 2014"
@ -41,15 +41,17 @@ getProgArgs = cmdArgs $ progArgs
main :: IO ()
main = getProgArgs >>= defaults >>= exec
-- Assign defaults value to unspecified args
-- Assign default values to unspecified args
defaults :: Args -> IO Args
defaults args@Args{..} = do
dictionary <- getDataFileName "dict/diceware" >>= readFile
defaultDict <- getDataFileName "dict/diceware" >>= readFile
dict <- readFile dictionary
return args
{ dictionary = dictionary
{ dictionary = if null dict then defaultDict else dict
, phraseLength = if phraseLength == 0 then 6 else phraseLength
}
-- Main function
exec :: Args -> IO ()
exec args@Args{..} =
if interactive
@ -61,4 +63,4 @@ exec args@Args{..} =
-- helpers
dice n = readDiceware (parseDiceware dictionary) (read n :: Int)
dice' n = readDiceware' (parseDiceware dictionary) n
dictSize = size $ parseDiceware dictionary
dictSize = length $ parseDiceware dictionary