www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Recommendation on option parsing

reply "Chris Piker" <chris hoopjump.com> writes:
Phobos' std.getopt is a bit spare for my taste, as there is
no builtin general help facility with word-wrapping.

Does anyone have a recommendation on which of the existing
command line option parsing libraries floating around in the
wild to use?  If it doesn't compile against the current
version of phobos I'm willing to put in a little work, but
since I'm very new to D I probably would not make the best
design decisions.

--
Chris
May 09 2014
next sibling parent reply Jacob Carlborg <doob me.com> writes:
On 2014-05-10 01:09, Chris Piker wrote:
 Phobos' std.getopt is a bit spare for my taste, as there is
 no builtin general help facility with word-wrapping.

 Does anyone have a recommendation on which of the existing
 command line option parsing libraries floating around in the
 wild to use?  If it doesn't compile against the current
 version of phobos I'm willing to put in a little work, but
 since I'm very new to D I probably would not make the best
 design decisions.
I'm using the one in Tango [1] with some additions [2]. It's a bit messy and I don't consider it stable, but it will automatically generate the help text. You can see some of it's uses here [3]. [1] https://github.com/SiegeLord/Tango-D2 [2] https://github.com/jacob-carlborg/mambo/tree/master/mambo/arguments [3] https://github.com/jacob-carlborg/dstep/blob/master/dstep/driver/Application.d#L53 -- /Jacob Carlborg
May 10 2014
parent "Chris Piker" <chris hoopjump.com> writes:
On Saturday, 10 May 2014 at 09:50:04 UTC, Jacob Carlborg wrote:
 On 2014-05-10 01:09, Chris Piker wrote:
 Phobos' std.getopt is a bit spare for my taste, as there is
 no builtin general help facility with word-wrapping.
 ...
I'm using the one in Tango [1] with some additions [2]. It's a bit messy and I don't consider it stable, but it will automatically generate the help text. You can see some of it's uses here [3]. [1] https://github.com/SiegeLord/Tango-D2 [2] https://github.com/jacob-carlborg/mambo/tree/master/mambo/arguments [3] https://github.com/jacob-carlborg/dstep/blob/master/dstep/driver/Application.d#L53
Thanks for the reference. Just perusing your class structure it looks like a well thought out module. Unfortunatly this also seems a heavy dependency to pull in, I have to use Tango and then mombo on top of that. Over the long haul that might be the best answer, but I'm working on a rather small set of programs for right now. -- Chris
May 12 2014
prev sibling next sibling parent reply Robert Schadek via Digitalmars-d-learn writes:
On 05/10/2014 01:09 AM, Chris Piker via Digitalmars-d-learn wrote:
 Phobos' std.getopt is a bit spare for my taste, as there is
 no builtin general help facility with word-wrapping.

 Does anyone have a recommendation on which of the existing
 command line option parsing libraries floating around in the
 wild to use?  If it doesn't compile against the current
 version of phobos I'm willing to put in a little work, but
 since I'm very new to D I probably would not make the best
 design decisions.

 -- 
 Chris
please help to make this happen https://github.com/D-Programming-Language/phobos/pull/2072
May 10 2014
parent reply "Chris Piker" <chris hoopjump.com> writes:
On Saturday, 10 May 2014 at 11:59:03 UTC, Robert Schadek via
Digitalmars-d-learn wrote:
 On 05/10/2014 01:09 AM, Chris Piker via Digitalmars-d-learn 
 wrote:
 Phobos' std.getopt is a bit spare for my taste, as there is
 no builtin general help facility with word-wrapping.
 ...
 --
 Chris
please help to make this happen https://github.com/D-Programming-Language/phobos/pull/2072
I'm not sure what you are asking for. Would you like me to tryout getoptEx? If so, then sure I can do that, why not. (Assuming I can figure out how to download your source file from github.) If you are asking me to affect phobos, well, that's a little out of my league for now. -- Chris
May 12 2014
parent reply Robert Schadek via Digitalmars-d-learn writes:
On 05/12/2014 10:44 PM, Chris Piker via Digitalmars-d-learn wrote:
 On Saturday, 10 May 2014 at 11:59:03 UTC, Robert Schadek via
 Digitalmars-d-learn wrote:
 On 05/10/2014 01:09 AM, Chris Piker via Digitalmars-d-learn wrote:
 Phobos' std.getopt is a bit spare for my taste, as there is
 no builtin general help facility with word-wrapping.
 ...
 -- 
 Chris
please help to make this happen https://github.com/D-Programming-Language/phobos/pull/2072
I'm not sure what you are asking for. Would you like me to tryout getoptEx? If so, then sure I can do that, why not. (Assuming I can figure out how to download your source file from github.)
yes please test it
May 12 2014
parent reply "Chris Piker" <chris hoopjump.com> writes:
On Monday, 12 May 2014 at 23:11:57 UTC, Robert Schadek via
Digitalmars-d-learn wrote:
 Chris
please help to make this happen https://github.com/D-Programming-Language/phobos/pull/2072
I'm not sure what you are asking for. Would you like me to tryout getoptEx?
yes please test it
Okay, I replaced the std.getopt that came with dmd with your version. My code compiles, but of course it doesn't link against the old libphobos.so. I'm a complete newbe to D and am not ready to build a new version of libphobos.so, that's for the library maintainers to do, which is not a job I'm ready to sign up for yet. Right now I'm just trying to get my own project done, and so far D's standard library is being a HUGE impediment. It's like programming against bare glibc all over again when I hoped it would be a little more like the Python standard libary. Just being a random developer my opinon isn't that important but, for what it's worth, I think an expanded option handling feature should be implemented in a separate module. That way users can try it out without affecting their existing libphobos. I like your enthusiasm. If you have any modules that don't require me to rebuild libphobos, I'll be happy to give them a whirl. Thank's for responding to my inquiry. -- Chris
May 12 2014
next sibling parent reply Robert Schadek via Digitalmars-d-learn writes:
On 05/13/2014 05:40 AM, Chris Piker via Digitalmars-d-learn wrote:
 On Monday, 12 May 2014 at 23:11:57 UTC, Robert Schadek via
 Digitalmars-d-learn wrote:

 Okay, I replaced the std.getopt that came with dmd with your
 version.  My code compiles, but of course it doesn't link
 against the old libphobos.so.  I'm a complete newbe to D and
 am not ready to build a new version of libphobos.so, that's
 for the library maintainers to do, which is not a job I'm ready
 to sign up for yet.  Right now I'm just trying to get my own
 project done, and so far D's standard library is being a HUGE
 impediment.  It's like programming against bare glibc all over
 again when I hoped it would be a little more like the Python
 standard libary.

 Just being a random developer my opinon isn't that important
 but, for what it's worth, I think an expanded option handling
 feature should be implemented in a separate module.  That way
 users can try it out without affecting their existing libphobos.

 I like your enthusiasm.  If you have any modules that don't
 require me to rebuild libphobos, I'll be happy to give them a
 whirl.  Thank's for responding to my inquiry.

 -- 
 Chris
Well, it is a pull request for std.getopt, therefore it can't stand alone. That been said, get into getopt.d and copy anything below line 1061 ( the begin of the comment for GetoptExRslt) into a new file. Add all imports from getopt.d + std.getopt and then add the new file to you're build. This allows you to use getoptEx without modifying your systems default libphobos.
May 13 2014
parent reply "Chris Piker" <chris hoopjump.com> writes:
 Okay, I replaced the std.getopt that came with dmd with your
 version.  My code compiles, but of course it doesn't link
 against the old libphobos.so.
Well, it is a pull request for std.getopt, therefore it can't stand alone. That been said, get into getopt.d and copy anything below line 1061 ( the begin of the comment for GetoptExRslt) into a new file. Add all imports from getopt.d + std.getopt and then add the new file to you're build. This allows you to use getoptEx without modifying your systems default libphobos.
I tried that, but you're using private members of std.getopt (which of course is okay for the way you intended the code to be used) so I stopped pursuing this solution. In fact, I used up all the schedule margin that I have for this small work project just trying to get decent command line handling. Since there is no more time to spare I've gone back to using python for my current tasks. I'll try to use D again sometime in the future. Hopefully someday the D community will coalesce a bit more around standard solutions for the un-exciting parts of programming. As a group you seem to do a great job at tackling the hard stuff. The logger project I saw on dub last night is a great example of the simple polish that I need D to have in order to make the switch from python for my day-to-day programming needs. Kind Regards -- Chris
May 13 2014
parent reply "Jesse Phillips" <Jesse.K.Phillips+D gmail.com> writes:
On Tuesday, 13 May 2014 at 17:05:15 UTC, Chris Piker wrote:
 I tried that, but you're using private members of std.getopt
 (which of course is okay for the way you intended the code
 to be used) so I stopped pursuing this solution.
Not sure why he had you break up the file. It should be as simple as changing the line "module std.getopt;" to something simple like "module getopt" then importing "import getopt;" and include the new file within the build. Anyway, D's libraries are not as extensive as Python/Ruby/Perl.
May 13 2014
next sibling parent "Chris Piker" <chris hoopjump.com> writes:
On Wednesday, 14 May 2014 at 04:15:04 UTC, Jesse Phillips wrote:
 Anyway, D's libraries are not as extensive as Python/Ruby/Perl.
True, but they wouldn't need to have much more to pass the good-enough threshold for me. In my current position I mostly write relatively simple server side programs. So a good logger + command line handling + cgi interface support is really enough for what I commonly do. An sftp library would be hand too, but I can find plenty of work for D to do without it. In the future I hope to investigate vibe.d, since a threaded, cross-platform, standalone server for our data would be nice to have. Cheers;
May 13 2014
prev sibling parent Robert Schadek via Digitalmars-d-learn writes:
On 05/14/2014 06:15 AM, Jesse Phillips via Digitalmars-d-learn wrote:
 On Tuesday, 13 May 2014 at 17:05:15 UTC, Chris Piker wrote:
 I tried that, but you're using private members of std.getopt
 (which of course is okay for the way you intended the code
 to be used) so I stopped pursuing this solution.
Not sure why he had you break up the file. It should be as simple as changing the line "module std.getopt;" to something simple like "module getopt" then importing "import getopt;" and include the new file within the build.
he is right, my bad
 Anyway, D's libraries are not as extensive as Python/Ruby/Perl.
May 14 2014
prev sibling parent reply "Vladimir Panteleev" <vladimir thecybershadow.net> writes:
On Tuesday, 13 May 2014 at 03:40:57 UTC, Chris Piker wrote:
 I like your enthusiasm.  If you have any modules that don't
 require me to rebuild libphobos, I'll be happy to give them a
 whirl.  Thank's for responding to my inquiry.
Try Digger! https://github.com/CyberShadow/Digger Or run the web interface (digger-web), and select the pull from the list.
May 13 2014
parent "Chris Piker" <chris hoopjump.com> writes:
On Tuesday, 13 May 2014 at 12:08:51 UTC, Vladimir Panteleev wrote:
 On Tuesday, 13 May 2014 at 03:40:57 UTC, Chris Piker wrote:
 I like your enthusiasm.  If you have any modules that don't
 require me to rebuild libphobos, I'll be happy to give them a
 whirl.  Thank's for responding to my inquiry.
Try Digger! https://github.com/CyberShadow/Digger Or run the web interface (digger-web), and select the pull from the list.
Thanks for the suggestion! I'll be happy to try it out next time I have an opportunity to use D. Unfortunately the window has closed on my current project. I just can't afford any more schedule slip. -- Chris
May 13 2014
prev sibling parent "albatroz" <rmcjustino gmail.com> writes:
Too late I see, but maybe next time it will provide you a way to 
search available projects faster.

On DUB http://code.dlang.org/ there is one project that looks 
like address the issues you had with std.getopt, "post-rock". 
Have not used it so I cannot give any further recommendations. 
Maybe you will find there others.

On Friday, 9 May 2014 at 23:09:34 UTC, Chris Piker wrote:
 Phobos' std.getopt is a bit spare for my taste, as there is
 no builtin general help facility with word-wrapping.

 Does anyone have a recommendation on which of the existing
 command line option parsing libraries floating around in the
 wild to use?  If it doesn't compile against the current
 version of phobos I'm willing to put in a little work, but
 since I'm very new to D I probably would not make the best
 design decisions.

 --
 Chris
May 14 2014