Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 17 additions & 6 deletions app/Main.hs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{-# LANGUAGE CPP #-}
module Main where

import Control.Monad (when)
Expand All @@ -11,6 +12,10 @@ import System.FilePath ((</>))
import System.IO
import Text.Read (readMaybe)

#if MIN_VERSION_Agda(2,8,0)
import Agda.Setup (setup)
#endif

main :: IO ()
main = do
-- set locale to UTF-8
Expand All @@ -19,6 +24,8 @@ main = do
hSetEncoding stdin utf8
hSetEncoding stderr utf8

-- getExecutablePath returns argv[0] in WASM, which is useless
#ifndef wasm32_HOST_ARCH
-- The GitHub CI-built executable lacks the correct data directory path.
-- If there's directory named "data" in the executable's directory,
-- then we assume that the executable is built by GitHub CI
Expand All @@ -28,14 +35,18 @@ main = do
isBuiltByCI <- doesDirectoryExist dataDir
when isBuiltByCI $ do
setEnv "Agda_datadir" dataDir
#endif

options <- getOptionsFromArgv
if optHelp options
then putStrLn usageMessage
else
if optVersion options
then putStrLn versionString
else do
case () of
_ | optHelp options -> putStrLn usageMessage
| optVersion options -> putStrLn versionString
#if MIN_VERSION_Agda(2,8,0)
| optSetup options -> do
setup True
return ()
#endif
| otherwise -> do
_ <- run options
-- _ <- run
return ()
10 changes: 9 additions & 1 deletion src/Options.hs
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,14 @@ usageMessage = usageInfo usage options ++ usageAboutAgdaOptions
data Options = Options
{ optViaTCP :: Maybe Int,
optRawAgdaOptions :: [String],
optSetup :: Bool,
optHelp :: Bool,
optVersion :: Bool
}

defaultOptions :: Options
defaultOptions =
Options {optViaTCP = Nothing, optRawAgdaOptions = [], optHelp = False, optVersion = False}
Options {optViaTCP = Nothing, optRawAgdaOptions = [], optSetup = False, optHelp = False, optVersion = False}

options :: [OptDescr (Options -> Options)]
options =
Expand All @@ -65,6 +66,13 @@ options =
"PORT"
)
"talk with the editor via TCP port (4096 as default)",
#if MIN_VERSION_Agda(2,8,0)
Option
[]
["setup"]
(NoArg (\opts -> opts {optSetup = True}))
"run Agda setup and exit",
#endif
Option
['V']
["version"]
Expand Down