Don't stop TUI on subcommand failure

This commit is contained in:
Julian Ospald 2020-07-28 21:53:54 +02:00
parent 86b0e4b31b
commit 7d334c18f5
No known key found for this signature in database
GPG Key ID: 511B62C09D50CD28
1 changed files with 12 additions and 13 deletions

View File

@ -175,19 +175,18 @@ withIOAction :: (AppState -> (Int, ListResult) -> IO (Either String a))
withIOAction action as = case listSelectedElement (lr as) of withIOAction action as = case listSelectedElement (lr as) of
Nothing -> continue as Nothing -> continue as
Just (ix, e) -> suspendAndResume $ do Just (ix, e) -> suspendAndResume $ do
r <- action as (ix, e) action as (ix, e) >>= \case
case r of Left err -> putStrLn $ ("Error: " <> err)
Left err -> throwIO $ userError err Right _ -> putStrLn "Success"
Right _ -> do apps <- (fmap . fmap)
apps <- (fmap . fmap) (\AppState {..} -> AppState { lr = listMoveTo ix lr, .. })
(\AppState {..} -> AppState { lr = listMoveTo ix lr, .. }) $ getAppState Nothing (pfreq as)
$ getAppState Nothing (pfreq as) case apps of
case apps of Right nas -> do
Right nas -> do putStrLn "Press enter to continue"
putStrLn "Press enter to continue" _ <- getLine
_ <- getLine pure nas
pure nas Left err -> throwIO $ userError err
Left err -> throwIO $ userError err
install' :: AppState -> (Int, ListResult) -> IO (Either String ()) install' :: AppState -> (Int, ListResult) -> IO (Either String ())