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
|
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
|
|
|
|
import System.Environment (getProgName)
|
|
|
|
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-03-20 11:56:00 +03:00
|
|
|
progn <- liftIO 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-03-21 15:09:34 +03:00
|
|
|
runTopCommand :: forall r. (Members '[EmbedIO, App, TaggedLock] r) => 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)
|
2023-11-06 16:56:20 +03:00
|
|
|
Init opts -> runLogIO (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
|
2023-11-06 14:49:43 +03:00
|
|
|
Clean opts -> runFilesIO (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
|
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
|