summaryrefslogtreecommitdiff
path: root/transfer/compile_to_core.hs
blob: b35d906d0a8bb2880348f0efe90c8e759d3e4961 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
module Main where

import Transfer.CompilerAPI

import Data.List (partition, isPrefixOf)
import System.Environment
import System.Exit
import System.IO

die :: String -> IO a
die s = do
        hPutStrLn stderr s
        exitFailure

main :: IO ()
main = do 
       args <- getArgs
       let (flags,files) = partition ("-" `isPrefixOf`) args
           path = [ p | ('-':'i':p) <- flags ]
       case files of
         [f] -> do
                cf <- compileFile path f
                putStrLn $ "Wrote " ++ cf
                return ()
         _   -> die "Usage: compile_to_core [-i<path> [-i<path> ... ]] <file>"