@@ -24,6 +24,7 @@ import Idris.ElabDecls
24import Idris.Primitives
24import Idris.Primitives
25import Idris.Imports
25import Idris.Imports
26import Idris.Error
26import Idris.Error
27+import Idris.CmdOptions
28import IRTS.System ( getLibFlags, getIdrisLibDir, getIncFlags )
29import IRTS.System ( getLibFlags, getIdrisLibDir, getIncFlags )
@@ -36,8 +37,7 @@ import Paths_idris
36-- Main program reads command line options, parses the main program, and gets
37-- Main program reads command line options, parses the main program, and gets
37-- on with the REPL.
38-- on with the REPL.
39−main = do xs <- getArgs
40+main = do opts <- runArgParser
40− let opts = parseArgs xs
41 result <- runErrorT $ execStateT (runIdris opts) idrisInit
41 result <- runErrorT $ execStateT (runIdris opts) idrisInit
42 case result of
42 case result of
43 Left err -> putStrLn $ "Uncaught error: " ++ show err
43 Left err -> putStrLn $ "Uncaught error: " ++ show err
@@ -48,8 +48,6 @@ runIdris [Client c] = do setVerbose False
48 setQuiet True
48 setQuiet True
49 runIO $ runClient c
49 runIO $ runClient c
50runIdris opts = do
50runIdris opts = do
51− when (Ver `elem` opts) $ runIO showver
52− when (Usage `elem` opts) $ runIO usage
53 when (ShowIncs `elem` opts) $ runIO showIncs
51 when (ShowIncs `elem` opts) $ runIO showIncs
54 when (ShowLibs `elem` opts) $ runIO showLibs
52 when (ShowLibs `elem` opts) $ runIO showLibs
55 when (ShowLibdir `elem` opts) $ runIO showLibdir
53 when (ShowLibdir `elem` opts) $ runIO showLibdir
@@ -72,9 +70,6 @@ runIdris opts = do
72 _ -> ifail "Too many packages"
70 _ -> ifail "Too many packages"
73 fs -> runIO $ mapM_ (buildPkg (WarnOnly `elem` opts)) fs
71 fs -> runIO $ mapM_ (buildPkg (WarnOnly `elem` opts)) fs
75−usage = do putStrLn usagemsg
78showver = do putStrLn $ "Idris version " ++ ver
73showver = do putStrLn $ "Idris version " ++ ver
79 exitWith ExitSuccess
74 exitWith ExitSuccess
@@ -89,59 +84,3 @@ showLibdir = do dir <- getIdrisLibDir
89showIncs = do incFlags <- getIncFlags
84showIncs = do incFlags <- getIncFlags
90 putStrLn incFlags
85 putStrLn incFlags
91 exitWith ExitSuccess
86 exitWith ExitSuccess
93−usagemsghdr = "Idris version " ++ ver ++ ", (C) The Idris Community 2014"
95−usagemsg = usagemsghdr ++ "\n" ++
96− map (\x -> '-') usagemsghdr ++ "\n" ++
97− "idris [OPTIONS] [FILE]\n\n" ++
99− "\t --install IPKG Install package\n" ++
100− "\t --clean IPKG Clean package\n" ++
101− "\t --build IPKG Build package\n" ++
102− "\t --mkdoc IPKG Generate IdrisDoc for package\n" ++
103− "\t -e --eval EXPR Evaluate an expression without loading the REPL\n" ++
104− "\t --exec EXPR Execute as idris\n" ++
105− "\t --libdir Display library directory\n" ++
106− "\t --link Display link flags\n" ++
107− "\t --include Display the includes flags\n" ++
108− "\t --nobanner Suppress the banner\n" ++
109− "\t --color, --colour Force coloured output\n" ++
110− "\t --nocolor, --nocolour Disable coloured output\n" ++
111− "\t --errorcontent Undocumented\n" ++
112− "\t --nocoverage Undocumented\n" ++
113− "\t -o --output FILE Specify output file\n" ++
114− "\t --check Undocumented\n" ++
115− "\t --total Require functions to be total by default\n" ++
116− "\t --partial Undocumented\n" ++
117− "\t --warnreach Warn about reachable but inaccessible arguments\n" ++
118− "\t --warnpartial Warn about undeclared partial functions.\n" ++
119− "\t --warn Undocumented\n" ++
120− "\t --typecase Undocumented\n" ++
121− "\t --typeintype Undocumented\n" ++
122− "\t --nobasepkgs Undocumented\n" ++
123− "\t --noprelude Undocumented\n" ++
124− "\t --nobuiltins Undocumented\n" ++
125− "\t -O --level LEVEL Undocumented\n" ++
126− "\t -i --idrispath DIR Add directory to the list of import paths\n" ++
127− "\t --package ITEM Undocumented\n" ++
128− "\t --ibcsubdir FILE Write IBC files into sub directory\n" ++
129− "\t --codegen TARGET Select code generator: C, Java, bytecode,\n" ++
130− "\t javascript, node, or llvm\n" ++
131− "\t --mvn Create a maven project (for Java codegen)\n" ++
132− "\t --cpu=CPU Select target CPU e.g. corei7 or cortex-m3\n" ++
133− "\t (for LLVM codegen)\n" ++
134− "\t --target=TRIPLE Select target triple (for llvm codegen)\n" ++
135− "\t -S --codegenonly Do no further compilation of code generator output\n" ++
136− "\t -c --compileonly Compile to object files rather than an executable\n" ++
137− "\t -X --extension EXT Turn on langage extension (TypeProviders or ErrorReflection)\n" ++
138− "\t --dumpdefuns Undocumented\n" ++
139− "\t --dumpcases Undocumented\n" ++
140− "\t --log LEVEL --loglevel Debugging log level\n" ++
141− "\t --ideslave Undocumented\n" ++
142− "\t --client Undocumented\n" ++
143− "\t -h --help Display help message\n" ++
144− "\t -v --version Print version information\n" ++
145− "\t -V --verbose Loud verbosity\n" ++
146− "\t -q --quiet Quiet verbosity\n"