Just curious... any plans to have an official user supplied set of packages or modules ala CPAN or ruby gems etc.?
Having a central repository of these kinds of things would probably increase D popularity. John Nick Sabalausky <[email protected]> wrote: >"Jesse Phillips" <[email protected]> wrote in message >news:[email protected]... >> Nick Sabalausky Wrote: >> >>> "Jesse Phillips" <[email protected]> wrote in message >>> news:[email protected]... >>> > >>> > 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); >> >> Interesting the similarities. I do provide more specialized functions for >> some of those: >> >> auto input2 = menu(promptMsg, ["coffee", "tea"]); >> >> auto input = require!(string, accept)(promptMsg); >> >> I haven't provide the option of displaying an error message, but it could >> go in the delegate you use in require. And I suppose prompt is a better >> name than userInput. >> > >Yea. I think mine is more customizable and generalized, but yours is more >batteries-included and ready-to-go (which makes yours very enticing). Maybe >we could merge our designs and come up with something suitable for Phobos? I >think this is the exactly the sort of thing that's a perfect fit for >inclusion in a std lib: Very handy, but for many people not big enough to >justify adding an external dependency. > >> On thing I've been kind of interested in is getting something set up that >> would allow providing the needed information via a config, args, or at >> runtime. but haven't done anything with that idea. >> > >That would be neat. > >One thing I'd been thinking of adding to mine was an alternate function that >just waited for a single keystroke (rather than a line of text + Enter). I >think I once had it working on Tango, IIRC, but then I switched to D2/Phobos >and couldn't figure out how to use Phobos to wait for a single keystroke w/o >then waiting for Enter. > >
