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
|
2024-06-05 13:23:24 +03:00
|
|
|
import Commands.Isabelle qualified as Isabelle
|
2023-11-10 15:55:36 +03:00
|
|
|
import Commands.Markdown qualified as Markdown
|
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
|
2024-11-25 20:28:24 +03:00
|
|
|
import System.Environment qualified as E
|
2022-09-14 17:16:15 +03:00
|
|
|
import TopCommand.Options
|
|
|
|
|
2024-03-20 11:56:00 +03:00
|
|
|
showHelpText :: (MonadIO m) => m ()
|
2022-09-14 17:16:15 +03:00
|
|
|
showHelpText = do
|
|
|
|
let p = prefs showHelpOnEmpty
|
2024-11-25 20:28:24 +03:00
|
|
|
progn <- liftIO E.getProgName
|
2022-09-14 17:16:15 +03:00
|
|
|
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)
|
|
|
|
|
2024-04-09 14:29:07 +03:00
|
|
|
runTopCommand ::
|
|
|
|
forall r.
|
2024-07-22 18:14:37 +03:00
|
|
|
(Members AppEffects r) =>
|
2024-04-09 14:29:07 +03:00
|
|
|
TopCommand ->
|
|
|
|
Sem r ()
|
2022-09-14 17:16:15 +03:00
|
|
|
runTopCommand = \case
|
2024-03-20 11:56:00 +03:00
|
|
|
DisplayVersion -> runDisplayVersion
|
|
|
|
DisplayNumericVersion -> runDisplayNumericVersion
|
|
|
|
DisplayHelp -> showHelpText
|
2022-09-14 17:16:15 +03:00
|
|
|
Doctor opts -> runLogIO (Doctor.runCommand opts)
|
2024-06-05 13:23:24 +03:00
|
|
|
Isabelle opts -> Isabelle.runCommand opts
|
2024-07-22 18:14:37 +03:00
|
|
|
Init opts -> Init.init opts
|
2022-09-14 17:16:15 +03:00
|
|
|
Dev opts -> Dev.runCommand opts
|
|
|
|
Typecheck opts -> Typecheck.runCommand opts
|
|
|
|
Compile opts -> Compile.runCommand opts
|
2024-07-22 18:14:37 +03:00
|
|
|
Clean opts -> Clean.runCommand opts
|
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
|
2023-11-10 15:55:36 +03:00
|
|
|
Markdown opts -> Markdown.runCommand opts
|
2022-11-07 16:47:56 +03:00
|
|
|
JuvixRepl opts -> Repl.runCommand opts
|
2024-07-22 18:14:37 +03:00
|
|
|
JuvixFormat opts -> Format.runCommand opts
|
2023-10-03 19:09:13 +03:00
|
|
|
Dependencies opts -> Dependencies.runCommand opts
|