3import System.Exit (ExitCode(..), exitSuccess, exitWith)
5import Control.Monad (unless, when, (>=>))
6import Data.Foldable (foldrM)
7import Data.Maybe (fromMaybe)
10import Idris.CmdOptions
17import Util.System (setupBundledCC)
19import System.Exit (ExitCode(..), exitWith)
20import Util.System (setupBundledCC)
22processShowOptions :: [Opt] -> Idris ()
23processShowOptions opts = runIO $ do
24 when (ShowAll `elem` opts) $ showExitIdrisInfo
25 when (ShowLoggingCats `elem` opts) $ showExitIdrisLoggingCategories
26 when (ShowIncs `elem` opts) $ showExitIdrisFlagsInc
27 when (ShowLibs `elem` opts) $ showExitIdrisFlagsLibs
28 when (ShowLibDir `elem` opts) $ showExitIdrisLibDir
29 when (ShowDocDir `elem` opts) $ showExitIdrisDocDir
30 when (ShowPkgs `elem` opts) $ showExitIdrisInstalledPackages
32check :: [Opt] -> (Opt -> Maybe a) -> ([a] -> Idris ()) -> Idris ()
33check opts extractOpts action = do
34 case opt extractOpts opts of
39processClientOptions :: [Opt] -> Idris ()
40processClientOptions opts = check opts getClient $ \fs -> case fs of
41 [] -> ifail "No --client argument. This indicates a bug. Please report."
46 Just DontListen -> ifail "\"--client\" and \"--port none\" are incompatible"
47 Just (ListenPort port) -> runIO $ runClient (Just port) c
48 Nothing -> runIO $ runClient Nothing c
50processPackageOptions :: [Opt] -> Idris ()
51processPackageOptions opts = do
52 check opts getPkgCheck $ \fs -> runIO $ do
53 mapM_ (checkPkg opts (WarnOnly `elem` opts) True) fs
54 check opts getPkgClean $ \fs -> runIO $ do
55 mapM_ (cleanPkg opts) fs
56 check opts getPkgMkDoc $ \fs -> runIO $ do
57 mapM_ (documentPkg opts) fs
58 check opts getPkgTest $ \fs -> runIO $ do
60 codes <- mapM (testPkg opts) fs
61 -- check if any of the tests exited with an exit code other
62 -- than zero; if they did, exit with exit code 1
63 unless (null $ filter (/= ExitSuccess) codes) $
64 exitWith (ExitFailure 1)
66 check opts getPkg $ \fs -> runIO $ do
67 mapM_ (buildPkg opts (WarnOnly `elem` opts)) fs
68 check opts getPkgREPL $ \fs -> case fs of
70 _ -> ifail "Too many packages"
72-- | The main function for the Idris executable.
73runIdris :: [Opt] -> Idris ()
76 processShowOptions opts -- Show information then quit.
77 processClientOptions opts -- Be a client to a REPL server.
78 processPackageOptions opts -- Work with Idris packages.
79 idrisMain opts -- Launch REPL or compile mode.
81-- Main program reads command line options, parses the main program, and gets
86 runMain (runIdris opts)
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list