+-- | Reads the request from the data file(s)
+readRequest :: Options -> [String] -> IO Request
+readRequest opts args = do
+ when (null args) $ do
+ hPutStrLn stderr "Error: this program needs an input file."
+ exitWith $ ExitFailure 1
+
+ input_data <- readFile (head args)
+ r1 <- case (parseData input_data) of
+ Bad err -> do
+ hPutStrLn stderr $ "Error: " ++ err
+ exitWith $ ExitFailure 1
+ Ok rq -> return rq
+ r2 <- if isJust (optDataFile opts) || (not . null . optNodeSim) opts
+ then do
+ cdata <- loadExternalData opts
+ let Request rqt _ = r1
+ return $ Request rqt cdata
+ else return r1
+ return r2
+