User packages/libs (Was: Just starting out)

John Arrizza cppgent0 at gmail.com
Fri Oct 14 12:30:59 PDT 2011


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 <a at a.a> wrote:

>"Jesse Phillips" <jessekphillips+D at gmail.com> wrote in message 
>news:j77s69$1j3d$1 at digitalmars.com...
>> Nick Sabalausky Wrote:
>>
>>> "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);
>>
>> 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.
>
>


More information about the Digitalmars-d mailing list