X-Git-Url: http://gitweb.michael.orlitzky.com/?p=hath.git;a=blobdiff_plain;f=src%2FMain.hs;h=7686ae30fb989e0cd3ee51d2dca2ac9e6980629b;hp=3dfa546e374c84b6c86cd2bdce848285d5fd2ea8;hb=3296c2f6578001f6a40de1b1e1f79b25c987d3af;hpb=60c61e5eb68575f723beac12fc3162ab30557953 diff --git a/src/Main.hs b/src/Main.hs index 3dfa546..7686ae3 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -18,7 +18,9 @@ import Cidr (Cidr, import CommandLine (help_set, help_text, input_function, - parse_errors) + Mode(..), + parse_errors, + parse_mode) -- Some exit codes, used in the ExitFailure constructor. exit_invalid_cidr :: Int @@ -126,8 +128,17 @@ main = do -- The input function we receive here should know what to read. inputfunc <- (CommandLine.input_function) input <- inputfunc + let cidr_strings = lines input mapM validate_or_die cidr_strings let cidrs = map Cidr.from_string cidr_strings - let regexes = map cidr_to_regex cidrs - putStrLn $ alternate regexes + + -- Get the mode of operation. + mode <- CommandLine.parse_mode + + case mode of + Regex -> do + let regexes = map cidr_to_regex cidrs + putStrLn $ alternate regexes + Reduce -> do + putStr input