Skip to content

Commit

Permalink
Update src/System/Hapistrano.hs
Browse files Browse the repository at this point in the history
Co-authored-by: Cristhian Motoche <CristhianMotoche@users.noreply.github.com>
  • Loading branch information
alexisbcc and CristhianMotoche authored Jul 19, 2024
1 parent de1c423 commit 5b56f2f
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/System/Hapistrano.hs
Original file line number Diff line number Diff line change
Expand Up @@ -292,15 +292,13 @@ initConfig getLine' = do
prompt :: Show a => String -> a -> MParser a -> IO a
prompt parameterName def parser = do
userInput <- prompt' (parameterName <> " (default: " <> show def <> ")")
if null userInput then
when (null userInput)
pure def
else do
let parsed = M.parse (parser <* M.eof) "" userInput
case parsed of
Left err -> do
hPutStrLn stderr (M.errorBundlePretty err)
prompt parameterName def parser
Right res -> pure res

either
(\err -> hPutStrLn stderr (M.errorBundlePretty err) >> prompt parameterName def parser)
pure
(M.parse (parser <* M.eof) "" userInput)

promptYN = do
userInput <- prompt "Include restart command? y/N" 'N' yNParser
Expand Down

0 comments on commit 5b56f2f

Please sign in to comment.