mirror of
https://github.com/gren-lang/compiler.git
synced 2024-09-11 16:56:29 +03:00
Don't prompt user if terminal is non-interactive.
This commit is contained in:
parent
51980e2de9
commit
82345d88d5
@ -31,6 +31,7 @@ where
|
|||||||
|
|
||||||
import Control.Concurrent
|
import Control.Concurrent
|
||||||
import Control.Exception (AsyncException (UserInterrupt), SomeException, catch, fromException, throw)
|
import Control.Exception (AsyncException (UserInterrupt), SomeException, catch, fromException, throw)
|
||||||
|
import GHC.IO.Handle (hIsTerminalDevice)
|
||||||
import Control.Monad (when)
|
import Control.Monad (when)
|
||||||
import Data.ByteString.Builder qualified as B
|
import Data.ByteString.Builder qualified as B
|
||||||
import Data.NonEmptyList qualified as NE
|
import Data.NonEmptyList qualified as NE
|
||||||
@ -130,11 +131,13 @@ ignorer =
|
|||||||
|
|
||||||
ask :: Bool -> D.Doc -> IO Bool
|
ask :: Bool -> D.Doc -> IO Bool
|
||||||
ask skipPrompts doc =
|
ask skipPrompts doc =
|
||||||
if skipPrompts
|
do
|
||||||
then pure True
|
interactive <- hIsTerminalDevice stdout
|
||||||
else do
|
if skipPrompts || not interactive
|
||||||
Help.toStdout doc
|
then pure True
|
||||||
askHelp
|
else do
|
||||||
|
Help.toStdout doc
|
||||||
|
askHelp
|
||||||
|
|
||||||
askHelp :: IO Bool
|
askHelp :: IO Bool
|
||||||
askHelp =
|
askHelp =
|
||||||
|
Loading…
Reference in New Issue
Block a user