Just starting out
Nick Sabalausky
a at a.a
Wed Oct 12 23:07:44 PDT 2011
"Jesse Phillips" <jessekphillips+d at gmail.com> wrote in message
news:j75t0k$2q6m$3 at digitalmars.com...
>
> I created a cmdln library to help with user interaction, which some seem
> to like.
>
> https://github.com/he-the-great/JPDLibs/tree/cmdln
>
Looks very nice. I have a similar (but probably more basic) thing, too (just
one function: "prompt"):
http://www.dsource.org/projects/semitwist/browser/trunk/src/semitwist/cmd/plain.d#L216
// -- Basic string prompt ------
string input1 = prompt("Type some stuff: ");
// -- String prompt with validation ------
// (failureMsg is optional)
string promptMsg = "Do you want 'coffee' or 'tea'? ";
string failureMsg = "Please enter 'coffee' or 'tea', not '%s'";
bool accept(string input)
{
return ["coffee", "tea"].contains(tolower(input));
}
// This will *not* return until the user enters a valid choice,
// so we don't need to do any more validation.
string input2 = prompt(promptMsg, &accept, failureMsg);
More information about the Digitalmars-d
mailing list