summoner-1.2.0: Tool for scaffolding completely configured production Haskell projects.

Safe HaskellNone
LanguageHaskell2010

Summoner.Question

Contents

Description

This module contains function to proper questioning in terminal.

Synopsis

Choose functions.

choose Source #

Arguments

:: 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.

chooseYesNo Source #

Arguments

:: YesNoPrompt

Target and Prompt

-> IO a

action for Y answer

-> IO a

action for N answer

-> IO a 

Like choose but the possible answer are Y or N.

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

Constructors

YesNoPrompt 

Fields

mkDefaultYesNoPrompt Source #

Arguments

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

query :: Text -> IO Text Source #

Queries for any answer.

  Short project description:
  ->

queryNotNull :: Text -> IO Text Source #

Queries for an non-empty answer.

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"