on master help sign in
Pretty print commands in errors
commitd583ccf6caf5820d5d664d2ba270a0b103b05cc9 authorTom Smalley <tfsmalley@gmail.com> dateFri 19 Oct 2018, 09:53 (8 years ago) parent7d4319d
3 files changed+4−1
lib/cliapp/src/Obelisk/CliApp.hs+1 lib/cliapp/src/Obelisk/CliApp/Process.hs+2 lib/command/src/Obelisk/Command.hs+1−1
lib/cliapp/src/Obelisk/CliApp.hs+1
@@ -41,6 +41,7 @@ module Obelisk.CliApp
4141 , createProcess_
4242 , callProcess
4343 , callCommand
44+ , reconstructCommand
4445 ) where
4546
4647import Control.Monad.Log (Severity (..))
lib/cliapp/src/Obelisk/CliApp/Process.hs+2
@@ -18,6 +18,7 @@ module Obelisk.CliApp.Process
1818 , createProcess_
1919 , callProcess
2020 , callCommand
21+ , reconstructCommand
2122 ) where
2223
2324import Control.Monad ((<=<), join, void)
@@ -166,6 +167,7 @@ streamToLog stream = fix $ \loop -> do
166167 Nothing -> return ()
167168 Just (sev, line) -> putLogRaw sev (T.decodeUtf8 line) >> loop
168169
170+-- | Pretty print a 'CmdSpec'
169171reconstructCommand :: Process.CmdSpec -> Text
170172reconstructCommand (Process.ShellCommand str) = T.pack str
171173reconstructCommand (Process.RawCommand c as) = processToShellString c as
lib/command/src/Obelisk/Command.hs+1−1
@@ -248,7 +248,7 @@ mkObeliskConfig = do
248248-- liftIO $ exitWith $ ExitFailure 2
249249 cliConf <- newCliConfig logLevel notInteractive notInteractive $ \case
250250 ObeliskError_ProcessError (ProcessFailure p code) ann ->
251− ( "Process exited with code " <> T.pack (show code) <> "; " <> T.pack (show p)
251+ ( "Process exited with code " <> T.pack (show code) <> "; " <> reconstructCommand p
252252 <> maybe "" ("\n\n" <>) ann
253253 , 2
254254 )