3import System.Exit (ExitCode(..), exitSuccess, exitWith)
5import Control.Monad (unless, when, (>=>))
6import Data.Foldable (foldrM)
7import Data.Maybe (fromMaybe)
10import Idris.CmdOptions
16import Util.System (setupBundledCC)
18import System.Exit (ExitCode(..), exitWith)
19import Util.System (setupBundledCC)
21processShowOptions :: [Opt] -> Idris ()
22processShowOptions opts = runIO $ do
23 when (ShowAll `elem` opts) $ showExitIdrisInfo
24 when (ShowLoggingCats `elem` opts) $ showExitIdrisLoggingCategories
25 when (ShowIncs `elem` opts) $ showExitIdrisFlagsInc
26 when (ShowLibs `elem` opts) $ showExitIdrisFlagsLibs
27 when (ShowLibDir `elem` opts) $ showExitIdrisLibDir
28 when (ShowDocDir `elem` opts) $ showExitIdrisDocDir
29 when (ShowPkgs `elem` opts) $ showExitIdrisInstalledPackages
31check :: [Opt] -> (Opt -> Maybe a) -> ([a] -> Idris ()) -> Idris ()
32check opts extractOpts action = do
33 case opt extractOpts opts of
38processClientOptions :: [Opt] -> Idris ()
39processClientOptions opts = check opts getClient $ \fs -> case fs of
40 [] -> ifail "No --client argument. This indicates a bug. Please report."
45 Just DontListen -> ifail "\"--client\" and \"--port none\" are incompatible"
46 Just (ListenPort port) -> runIO $ runClient (Just port) c
47 Nothing -> runIO $ runClient Nothing c
49processPackageOptions :: [Opt] -> Idris ()
50processPackageOptions opts = do
51 check opts getPkgCheck $ \fs -> runIO $ do
52 mapM_ (checkPkg opts (WarnOnly `elem` opts) True) fs
53 check opts getPkgClean $ \fs -> runIO $ do
54 mapM_ (cleanPkg opts) fs
55 check opts getPkgMkDoc $ \fs -> runIO $ do
56 mapM_ (documentPkg opts) fs
57 check opts getPkgTest $ \fs -> runIO $ do
59 codes <- mapM (testPkg opts) fs
60 -- check if any of the tests exited with an exit code other
61 -- than zero; if they did, exit with exit code 1
62 unless (null $ filter (/= ExitSuccess) codes) $
63 exitWith (ExitFailure 1)
65 check opts getPkg $ \fs -> runIO $ do
66 mapM_ (buildPkg opts (WarnOnly `elem` opts)) fs
67 check opts getPkgREPL $ \fs -> case fs of
69 _ -> ifail "Too many packages"
71-- | The main function for the Idris executable.
72runIdris :: [Opt] -> Idris ()
75 processShowOptions opts -- Show information then quit.
76 processClientOptions opts -- Be a client to a REPL server.
77 processPackageOptions opts -- Work with Idris packages.
78 idrisMain opts -- Launch REPL or compile mode.
80-- Main program reads command line options, parses the main program, and gets
85 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