Safe Haskell | None |
---|---|
Language | Haskell2010 |
This module contains function to proper questioning in terminal.
Synopsis
- choose :: Show a => (Text -> Maybe a) -> Text -> [a] -> IO a
- chooseYesNo :: YesNoPrompt -> IO a -> IO a -> IO a
- chooseYesNoBool :: YesNoPrompt -> IO Bool
- data YesNoPrompt = YesNoPrompt {
- yesNoTarget :: Text
- yesNoPrompt :: Text
- mkDefaultYesNoPrompt :: Text -> YesNoPrompt
- query :: Text -> IO Text
- queryNotNull :: Text -> IO Text
- queryDef :: Text -> Text -> IO Text
- queryManyRepeatOnFail :: forall a. (Text -> Maybe a) -> IO [a]
- checkUniqueName :: Text -> IO Text
- targetMessageWithText :: Bool -> Text -> Text -> IO Bool
- targetMessage :: Bool -> Text -> IO Bool
- trueMessage :: Text -> IO Bool
- falseMessage :: Text -> IO Bool
Choose functions.
:: Show a | |
=> (Text -> Maybe a) | Parse function |
-> Text | Question text. |
-> [a] | List of available options. |
-> IO a | The chosen option. |
Allows users to choose one of the given options. It asks the question until the appropriate answer is received.
:: YesNoPrompt | Target and Prompt |
-> IO a | action for |
-> IO a | action for |
-> IO a |
Like choose
but the possible answer are Y
or N
.
chooseYesNoBool :: YesNoPrompt -> IO Bool Source #
Like chooseYesNo
but returns Bool
.
YesNoPrompt
data YesNoPrompt Source #
Build a prompt
For example,
YesNoPrompt { yesNoTarget = Cabal , yesNoPrompt = "Do you want to add a cabal integration?"}
will generate a following prompt message to the user
Do you want to add a cabal integration? [y]/n -> y [Cabal] will be added to the project
YesNoPrompt | |
|
:: Text | target name |
-> YesNoPrompt |
Build a prompt with the TARGET name only
It will generate a simple default prompt such that
Add TARGET? [y]/n
Queries
queryDef :: Text -> Text -> IO Text Source #
Like query
but has the default answer if no answer is specified.
queryManyRepeatOnFail :: forall a. (Text -> Maybe a) -> IO [a] Source #
Queries many answers. If answers are not parsable shows the failing part and queries again
Customize target message
targetMessageWithText :: Bool -> Text -> Text -> IO Bool Source #
The message after yes/no questions. The output depends on the answer.
Benchmarks will be added to the project
targetMessage :: Bool -> Text -> IO Bool Source #
Like targetMessageWithText
but the text is "added to the project"