scriptlike.interact

Handling of interaction with users via standard input.

Provides functions for simple and common interactions with users in the form of question and answer.

Members

Classes

NoInputException
class NoInputException

Used when input was not provided.

Functions

menu
T menu(string question, Range options)

Creates a menu from a Range of strings.

pathLocation
string pathLocation(string action)

Gets a valid path folder from the user. The string will not contain quotes, if you are using in a system call and the path contain spaces wrapping in quotes may be required.

pause
void pause(string prompt)

Pauses and prompts the user to press Enter (or "Return" on OSX).

require
T require(string question, string failure)

Requires that a value be provided and valid based on the delegate passed in. It must also check against null input.

userInput
T userInput(string question)
void userInput(string question, T result)

The userInput function provides a means to accessing a single value from the user. Each invocation outputs a provided statement/question and takes an entire line of input. The result is then converted to the requested type; default is a string.

Manifest constants

defaultPausePrompt
enum defaultPausePrompt;
defaultPausePrompt
enum defaultPausePrompt;

Meta

Authors

Jesse Phillips

Synopsis:

import scriptlike.interact;

auto age = userInput!int("Please Enter you age");

if(userInput!bool("Do you want to continue?"))
{
    auto outputFolder = pathLocation("Where you do want to place the output?");
    auto color = menu!string("What color would you like to use?", ["Blue", "Green"]);
}

auto num = require!(int, "a > 0 && a <= 10")("Enter a number from 1 to 10");