@@ -1,5 +1,4 @@
1{-# LANGUAGE LambdaCase #-}
1{-# LANGUAGE LambdaCase #-}
2−{-# LANGUAGE MultiWayIf #-}
3module Obelisk.Command.CLI where
2module Obelisk.Command.CLI where
5import Control.Exception (finally)
4import Control.Exception (finally)
@@ -27,8 +26,9 @@ withSpinner s e f = do
27 isTerm <- hIsTerminalDevice stdout
26 isTerm <- hIsTerminalDevice stdout
28 -- When running in shell completion, disable the spinner. TODO: Do this using ReaderT and config.
27 -- When running in shell completion, disable the spinner. TODO: Do this using ReaderT and config.
29 inBashCompletion <- isInfixOf "completion" . unwords <$> getArgs
28 inBashCompletion <- isInfixOf "completion" . unwords <$> getArgs
30− if | not isTerm || inBashCompletion -> f
29+ case not isTerm || inBashCompletion of
31− | otherwise -> do
30+ True -> f
32 spinner <- dots1Spinner (1000 * 200) s
32 spinner <- dots1Spinner (1000 * 200) s
33 result <- finally f $ do
33 result <- finally f $ do
34 stopIndicator spinner
34 stopIndicator spinner
@@ -38,6 +38,7 @@ withSpinner s e f = do
38 return result
38 return result
40data Level = Level_Normal | Level_Warning | Level_Error
40data Level = Level_Normal | Level_Warning | Level_Error
41+ deriving (Bounded, Enum, Eq, Ord, Show)
42-- TODO: Handle this error cleanly when evaluating outside of `withSpinner` (eg: runCLI)
43-- TODO: Handle this error cleanly when evaluating outside of `withSpinner` (eg: runCLI)
43failWith :: Text -> IO a
44failWith :: Text -> IO a