From 699736be551da619d5f5734a4a0d6b37711a8fa1 Mon Sep 17 00:00:00 2001 From: Rnhmjoj Date: Thu, 16 Oct 2014 23:21:03 +0200 Subject: [PATCH] Fixes Dictionary specified path was ignored. Change to length since Diceware is a List --- main.hs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/main.hs b/main.hs index 260001c..071fa67 100644 --- a/main.hs +++ b/main.hs @@ -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