on master help sign in
Remove spinner in verbose commands of 'ob run'; and remove runCLI
f018fcdSridhar Ratnakumar
lib/command/src/Obelisk/Command.hs+2−3
@@ -18,8 +18,7 @@ import System.Environment
18import System.FilePath
18import System.FilePath
19import System.Posix.Process (executeFile)
19import System.Posix.Process (executeFile)
20
20
21−import Obelisk.Command.CLI (putErrorAndExit, putWarning, runCLI)
21+import Obelisk.Command.CLI (putErrorAndExit, putWarning)
22−import Obelisk.Command.Deploy
23import Obelisk.Command.Deploy
22import Obelisk.Command.Deploy
24import Obelisk.Command.Project
23import Obelisk.Command.Project
25import Obelisk.Command.Repl
24import Obelisk.Command.Repl
@@ -165,7 +164,7 @@ parserPrefs = defaultPrefs
165 }
164 }
166
165
167main :: IO ()
166main :: IO ()
168−main = runCLI $ do
167+main = do
169 myArgs <- getArgs
168 myArgs <- getArgs
170 --TODO: We'd like to actually use the parser to determine whether to hand off,
169 --TODO: We'd like to actually use the parser to determine whether to hand off,
171 --but in the case where this implementation of 'ob' doesn't support all
170 --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
16
16
17instance Exception AppError
17instance Exception AppError
18
18
19+-- TODO: When printing warnings and such, the spinner should let them be printed
20+-- in new line (above the spinner)
19withSpinner
21withSpinner
20 :: String -- ^ Text to print alongside the spinner
22 :: String -- ^ Text to print alongside the spinner
21 -> Maybe String -- ^ Optional text to print at the end
23 -> Maybe String -- ^ Optional text to print at the end
@@ -40,12 +42,10 @@ withSpinner s e f = do
40
42
41data Level = Level_Normal | Level_Warning | Level_Error
43data Level = Level_Normal | Level_Warning | Level_Error
42
44
43−runCLI :: IO () -> IO ()
44−runCLI = handle $ \(AppError err) -> putError err
45−
46-- | Prefer this over the alternative ways to exit the program with an error message as it automatically
45-- | Prefer this over the alternative ways to exit the program with an error message as it automatically
47-- takes care of cleaning on spinners.
46-- takes care of cleaning on spinners.
48-- TODO: Replace the uses of 'fail' throughout Stela to use this function.
47-- 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)
49putErrorAndExit :: Text -> IO ()
49putErrorAndExit :: Text -> IO ()
50putErrorAndExit = throw . AppError
50putErrorAndExit = throw . AppError
51
51
lib/command/src/Obelisk/Command/Nix.hs+1−1
@@ -62,7 +62,7 @@ nixBuild cfg = do
62 { std_out = CreatePipe
62 { std_out = CreatePipe
63 , std_err = CreatePipe
63 , std_err = CreatePipe
64 }
64 }
65− (withSpinner "Running nix-build ..." Nothing $ waitForProcess p) >>= \case
65+ withSpinner "Running nix-build ..." Nothing $ waitForProcess p >>= \case
66 ExitSuccess -> return ()
66 ExitSuccess -> return ()
67 _ -> do
67 _ -> do
68 -- FIXME: We should interleave `out` and `err` in their original order?
68 -- 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
177 , "shells." <> shellName
177 , "shells." <> shellName
178 , "--run", command
178 , "--run", command
179 ]
179 ]
180− void $ withSpinner "Launching project shell ..." Nothing $ do
181− waitForProcess ph
180+ void $ waitForProcess ph
182
181
183setCwd :: Maybe FilePath -> CreateProcess -> CreateProcess
182setCwd :: Maybe FilePath -> CreateProcess -> CreateProcess
184setCwd fp cp = cp { cwd = fp }
183setCwd fp cp = cp { cwd = fp }