Browse Source

Actually use the default answer in `ask`

tags/v0.2.2.0
Peter J. Jones 4 years ago
parent
commit
e2e48dae7f
1 changed files with 4 additions and 1 deletions
  1. 4
    1
      src/System/Console/Byline/Primary.hs

+ 4
- 1
src/System/Console/Byline/Primary.hs View File

@@ -68,8 +68,11 @@ ask prompt defans = do
Just s -> prompt <> text "[" <> text s <> "] "

answer <- liftInputT . getInputLine =<< renderPrompt prompt'
return (T.pack <$> answer)

return $ case answer of
Nothing -> Nothing
Just s | null s -> defans <|> (T.pack <$> answer)
| otherwise -> T.pack <$> answer

--------------------------------------------------------------------------------
-- | Read a single character of input. Like other functions,

Loading…
Cancel
Save