Update src/System/Hapistrano.hs

Co-authored-by: Cristhian Motoche <CristhianMotoche@users.noreply.github.com>
This commit is contained in:
Alexis Crespo 2024-07-18 21:32:45 -05:00 committed by GitHub
parent de1c4235f9
commit 5b56f2fc9c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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