byline-0.1.0.0: Library for creating command-line interfaces (colors, menus, etc.)

Safe HaskellNone
LanguageHaskell2010

System.Console.Byline.Primitive

Description

Primitive operations such as printing messages and reading input.

Synopsis

Documentation

data ReportType Source

Report types for the report function.

Constructors

Error

Report errors with: "error: "

Warning

Report warnings with: "warning: "

say :: MonadIO m => Stylized -> Byline m () Source

Output the stylized text to the output handle (default: stdout).

sayLn :: MonadIO m => Stylized -> Byline m () Source

Like say, but append a newline character.

ask Source

Arguments

:: MonadIO m 
=> Stylized

The prompt.

-> Maybe Text

Optional default answer that will be returned if the user presses return without providing any input (a zero-length string).

-> Byline m Text 

Read input after printing the given stylized text as a prompt.

askChar :: MonadIO m => Stylized -> Byline m Char Source

Read a single character of input.

askPassword Source

Arguments

:: MonadIO m 
=> Stylized

The prompt.

-> Maybe Char

Optional masking character that will be printed each time the user presses a key.

-> Byline m Text 

Read a password without echoing it to the terminal. If a masking character is given it will replace each typed character.

askUntil Source

Arguments

:: MonadIO m 
=> Stylized

The prompt.

-> Maybe Text

Optional default answer.

-> (Text -> m (Either Stylized Text))

Confirmation function.

-> Byline m Text 

Continue to prompt for a response until a confirmation function returns a valid result.

The confirmation function receives the output from ask and should return a Left Stylized to produce an error message (printed with sayLn). When an acceptable answer from ask is received, the confirmation function should return it with Right.

report :: MonadIO m => ReportType -> Stylized -> Byline m () Source

Output stylized text with a prefix determined by ReportType.

reportLn :: MonadIO m => ReportType -> Stylized -> Byline m () Source

Like report, but append a newline character.

withCompletionFunc :: MonadIO m => CompletionFunc -> Byline m a -> Byline m a Source

Run the given Byline action with a different completion function.