1
1
mirror of https://github.com/anoma/juvix.git synced 2024-12-15 01:52:11 +03:00
juvix/app/Main.hs
Paul Cadman cbee146bd7
Rename Roots type to Root (#2480)
This was suggested by @jonaprieto in
https://github.com/anoma/juvix/pull/2458#discussion_r1368476371 - but we
deferred it until the Package file PR sequence was merged.
2023-10-30 14:05:52 +01:00

35 lines
1.0 KiB
Haskell

{-# LANGUAGE QuasiQuotes #-}
module Main (main) where
import App
import CommonOptions
import Data.String.Interpolate (i)
import GlobalOptions
import Juvix.Compiler.Pipeline.Root
import TopCommand
import TopCommand.Options
main :: IO ()
main = do
let parserPreferences = prefs showHelpOnEmpty
invokeDir <- getCurrentDir
(_runAppIOArgsGlobalOptions, cli) <- customExecParser parserPreferences descr
mbuildDir <- mapM (prepathToAbsDir invokeDir) (_runAppIOArgsGlobalOptions ^? globalBuildDir . _Just . pathPath)
mainFile <- topCommandInputPath cli
mapM_ checkMainFile mainFile
_runAppIOArgsRoot <- findRootAndChangeDir (containingDir <$> mainFile) mbuildDir invokeDir
runFinal
. resourceToIOFinal
. embedToFinal @IO
. runAppIO RunAppIOArgs {..}
$ runTopCommand cli
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