Skip to content

Commit

Permalink
Rewriting main so that it passes a disabled backend when run in inter…
Browse files Browse the repository at this point in the history
…active mode
  • Loading branch information
viktorcsimma authored and jespercockx committed Oct 22, 2023
1 parent 95bf6f6 commit 48c98b5
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ backend = Backend'
, options = defaultOptions
, commandLineFlags =
[ Option ['d'] ["disable-backend"] (NoArg disableOpt)
"Disable backend and fall back to vanilla Agda behaviour, without compilation (important for Emacs mode)."
"Disable backend and fall back to vanilla Agda behaviour, without compilation (important for Emacs mode). Implied when run in interactive mode (with --interactive, --interaction or --interaction-json)."
, Option ['o'] ["out-dir"] (ReqArg outdirOpt "DIR")
"Write Haskell code to DIR. (default: project root)"
, Option ['X'] [] (ReqArg extensionOpt "EXTENSION")
Expand All @@ -74,8 +74,17 @@ backend = Backend'
, mayEraseType = \ _ -> return True
}

main = do
-- Issue #201: drop backend when running in interactive mode
-- Checking whether we are in interactive mode.
-- These will imply --disable-backend.
isInteractive :: IO Bool
isInteractive = do
let interactionFlag = Option ['I'] ["interactive", "interaction", "interaction-json"] (NoArg ()) ""
(i , _ , _) <- getOpt Permute [interactionFlag] <$> getArgs
runAgda [Backend backend | null i ]
return $ not $ null i

main = do
-- Issue #201: drop backend when run in interactive mode
isInt <- isInteractive
if isInt
then runAgda [Backend (backend{isEnabled = const False})]
else runAgda [Backend backend]

0 comments on commit 48c98b5

Please sign in to comment.