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


import scriptlike.interact;

auto age = userInput!int("Please Enter your 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");


menu(question, options) Creates a menu from a Range of strings.
pathLocation(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(prompt) Pauses and prompts the user to press Enter (or "Return" on OSX).
require(question, failure) Requires that a value be provided and valid based on the delegate passed in. It must also check against null input.
userInput(question) 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.


NoInputException Used when input was not provided.

Manifest constants