X-Git-Url: http://gitweb.michael.orlitzky.com/?p=dead%2Fhalcyon.git;a=blobdiff_plain;f=src%2FCommandLine.hs;h=0b081bc5a7d752fefe85652d0c1f6e92bd124466;hp=db3b12da2039c6de2d046bf04e22782849b32649;hb=d721869c5e7395c021cc79f40720bdb275d613d2;hpb=dd6cea3dc5e830691b1da442fcf91602e4cf94aa diff --git a/src/CommandLine.hs b/src/CommandLine.hs index db3b12d..0b081bc 100644 --- a/src/CommandLine.hs +++ b/src/CommandLine.hs @@ -150,7 +150,7 @@ set_heartbeat arg opts = do return opts { opt_heartbeat = new_heartbeat } set_help :: Options -> IO Options -set_help opts = do +set_help opts = return opts { opt_help = True } set_ignore_retweets :: Options -> IO Options @@ -211,19 +211,14 @@ parse_options = do heartbeat_errors :: IO [String] heartbeat_errors = do hb <- parse_heartbeat - if (isNothing hb) - then return ["\"heartbeat\" does not appear to be an integer."] - else return [] + return ["\"heartbeat\" does not appear to be an integer." | isNothing hb ] -- | Parse errors relating to the list of usernames. username_errors :: IO [String] username_errors = do argv <- getArgs let (_, usernames, _) = getOpt Permute options argv - - if (null usernames) - then return ["no usernames provided."] - else return [] + return [ "no usernames provided." | null usernames ] -- | Parse errors relating to the "To" address. @@ -231,9 +226,8 @@ to_errors :: IO [String] to_errors = do toaddr <- parse_to_address fromaddr <- parse_from_address - if (isNothing toaddr) && (isJust fromaddr) - then return ["\"from\" address specified without \"to\" address."] - else return [] + return ["\"from\" address specified without \"to\" address." + | (isNothing toaddr) && (isJust fromaddr) ] -- | Errors for the sendmail path argument. @@ -241,9 +235,7 @@ sendmail_path_errors :: IO [String] sendmail_path_errors = do sendmail <- parse_sendmail_path exists <- doesFileExist sendmail - if (not exists) - then return ["sendmail path does not exist"] - else return [] + return [ "sendmail path does not exist" | not exists ] -- | Parse errors relating to the "From" address. @@ -251,9 +243,8 @@ from_errors :: IO [String] from_errors = do toaddr <- parse_to_address fromaddr <- parse_from_address - if (isJust toaddr) && (isNothing fromaddr) - then return ["\"to\" address specified without \"from\" address."] - else return [] + return [ "\"to\" address specified without \"from\" address." + | (isJust toaddr) && (isNothing fromaddr) ] -- | Format an error message for printing.