on master help sign in
Remove spinner in verbose commands of 'ob run'; and remove runCLI
commitf018fcd754322924c6f7718f7ded21fbf7b49ec2 authorSridhar Ratnakumar <srid@srid.ca> dateTue 8 May 2018, 19:11 (8 years ago) parent5e8fcce
4 files changed+7−9
lib/command/src/Obelisk/Command.hs+2−3 lib/command/src/Obelisk/Command/CLI.hs+3−3 lib/command/src/Obelisk/Command/Nix.hs+1−1 lib/command/src/Obelisk/Command/Project.hs+1−2
lib/command/src/Obelisk/Command.hs+2−3
@@ -18,8 +18,7 @@ import System.Environment
1818import System.FilePath
1919import System.Posix.Process (executeFile)
2020
21−import Obelisk.Command.CLI (putErrorAndExit, putWarning, runCLI)
22−import Obelisk.Command.Deploy
21+import Obelisk.Command.CLI (putErrorAndExit, putWarning)
2322import Obelisk.Command.Deploy
2423import Obelisk.Command.Project
2524import Obelisk.Command.Repl
@@ -165,7 +164,7 @@ parserPrefs = defaultPrefs
165164 }
166165
167166main :: IO ()
168−main = runCLI $ do
167+main = do
169168 myArgs <- getArgs
170169 --TODO: We'd like to actually use the parser to determine whether to hand off,
171170 --but in the case where this implementation of 'ob' doesn't support all
lib/command/src/Obelisk/Command/CLI.hs+3−3
@@ -16,6 +16,8 @@ newtype AppError = AppError Text
1616
1717instance Exception AppError
1818
19+-- TODO: When printing warnings and such, the spinner should let them be printed
20+-- in new line (above the spinner)
1921withSpinner
2022 :: String -- ^ Text to print alongside the spinner
2123 -> Maybe String -- ^ Optional text to print at the end
@@ -40,12 +42,10 @@ withSpinner s e f = do
4042
4143data Level = Level_Normal | Level_Warning | Level_Error
4244
43−runCLI :: IO () -> IO ()
44−runCLI = handle $ \(AppError err) -> putError err
45−
4645-- | Prefer this over the alternative ways to exit the program with an error message as it automatically
4746-- takes care of cleaning on spinners.
4847-- TODO: Replace the uses of 'fail' throughout Stela to use this function.
48+-- TODO: Handle this error cleanly when evaluating outside of `withSpinner` (eg: runCLI)
4949putErrorAndExit :: Text -> IO ()
5050putErrorAndExit = throw . AppError
5151
lib/command/src/Obelisk/Command/Nix.hs+1−1
@@ -62,7 +62,7 @@ nixBuild cfg = do
6262 { std_out = CreatePipe
6363 , std_err = CreatePipe
6464 }
65− (withSpinner "Running nix-build ..." Nothing $ waitForProcess p) >>= \case
65+ withSpinner "Running nix-build ..." Nothing $ waitForProcess p >>= \case
6666 ExitSuccess -> return ()
6767 _ -> do
6868 -- FIXME: We should interleave `out` and `err` in their original order?
lib/command/src/Obelisk/Command/Project.hs+1−2
@@ -177,8 +177,7 @@ projectShell root isPure shellName command = do
177177 , "shells." <> shellName
178178 , "--run", command
179179 ]
180− void $ withSpinner "Launching project shell ..." Nothing $ do
181− waitForProcess ph
180+ void $ waitForProcess ph
182181
183182setCwd :: Maybe FilePath -> CreateProcess -> CreateProcess
184183setCwd fp cp = cp { cwd = fp }