2022-01-18 14:25:42 +03:00
|
|
|
module Main (main) where
|
|
|
|
|
2022-05-18 18:10:10 +03:00
|
|
|
import App
|
2022-09-14 17:16:15 +03:00
|
|
|
import CommonOptions
|
2023-05-15 12:03:09 +03:00
|
|
|
import Data.String.Interpolate (i)
|
2023-04-13 12:27:39 +03:00
|
|
|
import GlobalOptions
|
|
|
|
import Juvix.Compiler.Pipeline.Root
|
2022-09-14 17:16:15 +03:00
|
|
|
import TopCommand
|
|
|
|
import TopCommand.Options
|
2022-03-25 02:52:30 +03:00
|
|
|
|
2022-09-14 17:16:15 +03:00
|
|
|
main :: IO ()
|
|
|
|
main = do
|
2023-01-06 19:54:13 +03:00
|
|
|
let parserPreferences = prefs showHelpOnEmpty
|
2023-04-13 12:27:39 +03:00
|
|
|
invokeDir <- getCurrentDir
|
2023-01-06 19:54:13 +03:00
|
|
|
(_runAppIOArgsGlobalOptions, cli) <- customExecParser parserPreferences descr
|
2023-04-19 17:56:48 +03:00
|
|
|
mbuildDir <- mapM (prepathToAbsDir invokeDir) (_runAppIOArgsGlobalOptions ^? globalBuildDir . _Just . pathPath)
|
2023-05-15 12:03:09 +03:00
|
|
|
mainFile <- topCommandInputPath cli
|
|
|
|
mapM_ checkMainFile mainFile
|
2024-03-21 15:09:34 +03:00
|
|
|
runM
|
2023-12-06 20:24:59 +03:00
|
|
|
. runTaggedLockPermissive
|
|
|
|
$ do
|
|
|
|
_runAppIOArgsRoot <- findRootAndChangeDir (containingDir <$> mainFile) mbuildDir invokeDir
|
|
|
|
runAppIO RunAppIOArgs {..} (runTopCommand cli)
|
2023-05-15 12:03:09 +03:00
|
|
|
where
|
|
|
|
checkMainFile :: SomePath b -> IO ()
|
|
|
|
checkMainFile p = unlessM (doesSomePathExist p) err
|
|
|
|
where
|
|
|
|
err :: IO ()
|
|
|
|
err = do
|
|
|
|
hPutStrLn stderr [i|The input path #{p} does not exist|]
|
|
|
|
exitFailure
|