Skip to content

Commit

Permalink
Don't prompt user if terminal is non-interactive.
Browse files Browse the repository at this point in the history
  • Loading branch information
robinheghan committed Jun 22, 2024
1 parent 51980e2 commit 82345d8
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions builder/src/Reporting.hs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ where

import Control.Concurrent
import Control.Exception (AsyncException (UserInterrupt), SomeException, catch, fromException, throw)
import GHC.IO.Handle (hIsTerminalDevice)
import Control.Monad (when)
import Data.ByteString.Builder qualified as B
import Data.NonEmptyList qualified as NE
Expand Down Expand Up @@ -130,11 +131,13 @@ ignorer =

ask :: Bool -> D.Doc -> IO Bool
ask skipPrompts doc =
if skipPrompts
then pure True
else do
Help.toStdout doc
askHelp
do
interactive <- hIsTerminalDevice stdout
if skipPrompts || not interactive
then pure True
else do
Help.toStdout doc
askHelp

askHelp :: IO Bool
askHelp =
Expand Down

0 comments on commit 82345d8

Please sign in to comment.