2022-09-14 17:16:15 +03:00
|
|
|
module TopCommand where
|
|
|
|
|
2023-03-29 16:51:04 +03:00
|
|
|
import Commands.Base hiding (Format)
|
2023-04-21 15:21:31 +03:00
|
|
|
import Commands.Clean qualified as Clean
|
2022-09-14 17:16:15 +03:00
|
|
|
import Commands.Compile qualified as Compile
|
2023-10-03 19:09:13 +03:00
|
|
|
import Commands.Dependencies qualified as Dependencies
|
2022-09-14 17:16:15 +03:00
|
|
|
import Commands.Dev qualified as Dev
|
|
|
|
import Commands.Doctor qualified as Doctor
|
2023-03-14 18:24:07 +03:00
|
|
|
import Commands.Eval qualified as Eval
|
2023-03-29 16:51:04 +03:00
|
|
|
import Commands.Format qualified as Format
|
2022-09-14 17:16:15 +03:00
|
|
|
import Commands.Html qualified as Html
|
|
|
|
import Commands.Init qualified as Init
|
2022-11-07 16:47:56 +03:00
|
|
|
import Commands.Repl qualified as Repl
|
2022-09-14 17:16:15 +03:00
|
|
|
import Commands.Typecheck qualified as Typecheck
|
|
|
|
import Juvix.Extra.Version
|
|
|
|
import System.Environment (getProgName)
|
|
|
|
import TopCommand.Options
|
|
|
|
|
|
|
|
showHelpText :: IO ()
|
|
|
|
showHelpText = do
|
|
|
|
let p = prefs showHelpOnEmpty
|
|
|
|
progn <- getProgName
|
|
|
|
let helpText = parserFailure p descr (ShowHelpText Nothing) []
|
2023-01-17 11:41:07 +03:00
|
|
|
(msg, _) = renderFailure helpText progn
|
2022-09-14 17:16:15 +03:00
|
|
|
putStrLn (pack msg)
|
|
|
|
|
2023-03-29 16:51:04 +03:00
|
|
|
runTopCommand :: forall r. (Members '[Embed IO, App, Resource] r) => TopCommand -> Sem r ()
|
2022-09-14 17:16:15 +03:00
|
|
|
runTopCommand = \case
|
|
|
|
DisplayVersion -> embed runDisplayVersion
|
2023-03-24 12:45:53 +03:00
|
|
|
DisplayNumericVersion -> embed runDisplayNumericVersion
|
2022-09-14 17:16:15 +03:00
|
|
|
DisplayHelp -> embed showHelpText
|
|
|
|
Doctor opts -> runLogIO (Doctor.runCommand opts)
|
|
|
|
Init -> runLogIO Init.init
|
|
|
|
Dev opts -> Dev.runCommand opts
|
|
|
|
Typecheck opts -> Typecheck.runCommand opts
|
|
|
|
Compile opts -> Compile.runCommand opts
|
2023-04-21 15:21:31 +03:00
|
|
|
Clean -> runFilesIO Clean.runCommand
|
2023-03-14 18:24:07 +03:00
|
|
|
Eval opts -> Eval.runCommand opts
|
2022-09-14 17:16:15 +03:00
|
|
|
Html opts -> Html.runCommand opts
|
2022-11-07 16:47:56 +03:00
|
|
|
JuvixRepl opts -> Repl.runCommand opts
|
2023-03-29 16:51:04 +03:00
|
|
|
JuvixFormat opts -> runFilesIO (Format.runCommand opts)
|
2023-10-03 19:09:13 +03:00
|
|
|
Dependencies opts -> Dependencies.runCommand opts
|