@@ -16,17 +16,19 @@ import Paths_idris
17import Util.System
17import Util.System
19+data Opts = Opts { really :: Bool,
19−data Opts = Opts { inputs :: [FilePath],
20+ inputs :: [FilePath],
20 interface :: Bool,
21 interface :: Bool,
21 output :: FilePath }
22 output :: FilePath }
23−showUsage = do putStrLn "Usage: idris-c <ibc-files> [-o <output-file>]"
24+showUsage = do putStrLn "Usage: idris-codegen-c --yes-really <ibc-files> [-o <output-file>]"
24 exitWith ExitSuccess
25 exitWith ExitSuccess
26getOpts :: IO Opts
27getOpts :: IO Opts
27getOpts = do xs <- getArgs
28getOpts = do xs <- getArgs
28− return $ process (Opts [] False "a.out") xs
29+ return $ process (Opts False [] False "a.out") xs
31+ process opts ("--yes-really":xs) = process (opts { really = True }) xs
30 process opts ("-o":o:xs) = process (opts { output = o }) xs
32 process opts ("-o":o:xs) = process (opts { output = o }) xs
31 process opts ("--interface":xs) = process (opts { interface = True }) xs
33 process opts ("--interface":xs) = process (opts { interface = True }) xs
32 process opts (x:xs) = process (opts { inputs = x:inputs opts }) xs
34 process opts (x:xs) = process (opts { inputs = x:inputs opts }) xs
@@ -36,7 +38,7 @@ c_main :: Opts -> Idris ()
36c_main opts = do runIO setupBundledCC
38c_main opts = do runIO setupBundledCC
38 loadInputs (inputs opts) Nothing
40 loadInputs (inputs opts) Nothing
39− mainProg <- if interface opts
41+ mainProg <- if interface opts
40 then liftM Just elabMain
42 then liftM Just elabMain
41 else return Nothing
43 else return Nothing
42 ir <- compile (Via "c") (output opts) mainProg
44 ir <- compile (Via "c") (output opts) mainProg
@@ -44,9 +46,9 @@ c_main opts = do runIO setupBundledCC
45main :: IO ()
47main :: IO ()
46main = do opts <- getOpts
48main = do opts <- getOpts
47− if (null (inputs opts))
49+ if (null (inputs opts))
48 then showUsage
50 then showUsage
51+ else if (not $ really opts)
52+ then do putStrLn "This is not what you may expect it is."
49− else runMain (c_main opts)
54+ else runMain (c_main opts)