Jump to page: 1 2
Thread overview
optparse module
Apr 14, 2006
Daniel Keep
Apr 14, 2006
John C
Apr 14, 2006
Daniel Keep
Apr 14, 2006
Frank Benoit
Apr 14, 2006
Daniel Keep
Apr 14, 2006
Lars Ivar Igesund
Apr 14, 2006
Daniel Keep
Apr 15, 2006
Daniel Keep
Apr 14, 2006
jcc7
Apr 14, 2006
Frank Benoit
Apr 14, 2006
Daniel Keep
Apr 14, 2006
jcc7
Apr 14, 2006
pragma
Apr 14, 2006
pragma
April 14, 2006
Me again :P

I found I needed something to dump a file as hex the other day, so naturally the first thing I wrote was a command-line argument parser :P

Here's the preliminary version, and since I can't see anything similar in either phobos or on dsource, I thought I'd post it up here to see if anyone thinks I should try getting it online somewhere.

So comments, criticisms and suggestions all welcome.  The archive contains the module itself, a module to fix the problem with std.boxer, and a test program.  It builds just fine with either

$ build optparse_test

or

$ dmd optparse_test.d optparse.d dmdbug_std_boxer_assert.d

So let me know what you think.  And thanks for all the help with getting this to work :)

	-- Daniel

-- 

v1sw5+8Yhw5ln4+5pr6OFma8u6+7Lw4Tm6+7l6+7D a2Xs3MSr2e4/6+7t4TNSMb6HTOp5en5g6RAHCP    http://hackerkey.com/


April 14, 2006
Daniel Keep wrote:
> Me again :P
> 
> I found I needed something to dump a file as hex the other day, so
> naturally the first thing I wrote was a command-line argument parser :P
> 
> Here's the preliminary version, and since I can't see anything similar
> in either phobos or on dsource, I thought I'd post it up here to see if
> anyone thinks I should try getting it online somewhere.

I was looking for a command-line parser just yesterday. Searching the newsgroups, I found this: http://www.digitalmars.com/d/archives/digitalmars/D/announce/553.html

It's called ... er ... optparse ... just like yours. I guess after the Python library?

> 
> So comments, criticisms and suggestions all welcome.  The archive
> contains the module itself, a module to fix the problem with std.boxer,
> and a test program.  It builds just fine with either
> 
> $ build optparse_test
> 
> or
> 
> $ dmd optparse_test.d optparse.d dmdbug_std_boxer_assert.d
> 
> So let me know what you think.  And thanks for all the help with getting
> this to work :)
> 
> 	-- Daniel
> 

I'll have to try it out. Looks promising. Is there support for "/"-style options as well as the GNU/POSIX syntax?
April 14, 2006
Or this one

http://svn.dsource.org/projects/ddl/trunk/utils/ArgParser.d
April 14, 2006
In article <e1ocf1$2iej$1@digitaldaemon.com>, Daniel Keep says...
>
>This is a multi-part message in MIME format.
>--------------090201060608040605000801
>Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit
>
>Me again :P
>
>I found I needed something to dump a file as hex the other day, so naturally the first thing I wrote was a command-line argument parser :P
>
>Here's the preliminary version, and since I can't see anything similar in either phobos or on dsource, I thought I'd post it up here to see if anyone thinks I should try getting it online somewhere.

Something like really needs to be added to Phobos since it's such a popular idea. I created a wiki page to list the existing modules (including this newest one): http://www.prowiki.org/wiki4d/wiki.cgi?Phobos/PosixGetOpt

jcc7
April 14, 2006
In Java I loved to use JCmdLine http://jcmdline.sourceforge.net/

Perhaps someone wants to port it :D
Or someone knows how to use the j2d or language machine or something
like that.

April 14, 2006

John C wrote:
> Daniel Keep wrote:
>> Me again :P
>>
>> I found I needed something to dump a file as hex the other day, so naturally the first thing I wrote was a command-line argument parser :P
>>
>> Here's the preliminary version, and since I can't see anything similar in either phobos or on dsource, I thought I'd post it up here to see if anyone thinks I should try getting it online somewhere.
> 
> I was looking for a command-line parser just yesterday. Searching the newsgroups, I found this: http://www.digitalmars.com/d/archives/digitalmars/D/announce/553.html
> 

Man, I suck at finding things...

> It's called ... er ... optparse ... just like yours. I guess after the Python library?
> 

Wow.  It's... pretty damn close to mine :P

>>
>> So comments, criticisms and suggestions all welcome.  The archive contains the module itself, a module to fix the problem with std.boxer, and a test program.  It builds just fine with either
>>
>> $ build optparse_test
>>
>> or
>>
>> $ dmd optparse_test.d optparse.d dmdbug_std_boxer_assert.d
>>
>> So let me know what you think.  And thanks for all the help with getting this to work :)
>>
>>     -- Daniel
>>
> 
> I'll have to try it out. Looks promising. Is there support for "/"-style options as well as the GNU/POSIX syntax?

Not at the moment, no.  Since it was based on Python's optparse, I went with its syntax, although I was thinking on how to support different option styles.  I couldn't decide between having a compile-time switch, or being able to override bits and pieces at runtime, so I just put it off :P

Besides, I still have to get short option concatenation working...

	-- Daniel

-- 

v1sw5+8Yhw5ln4+5pr6OFma8u6+7Lw4Tm6+7l6+7D a2Xs3MSr2e4/6+7t4TNSMb6HTOp5en5g6RAHCP    http://hackerkey.com/
April 14, 2006
Frank Benoit wrote:
> Or this one
> 
> http://svn.dsource.org/projects/ddl/trunk/utils/ArgParser.d

That one's pretty nice; much shorter than mine.

But then, mine produces a hash of boxes of pre-formatted values.  With that one, you have to write a new delegate for each option.

Plus, it doesn't have the way, way cool OptionParser.showHelp() method ^_^.

	-- Daniel

-- 

v1sw5+8Yhw5ln4+5pr6OFma8u6+7Lw4Tm6+7l6+7D a2Xs3MSr2e4/6+7t4TNSMb6HTOp5en5g6RAHCP    http://hackerkey.com/
April 14, 2006
Yup.  Definitely need to learn to look better :P

In all honesty, I never liked getopt.  Too fiddly for my tastes.  I suppose in the end, the good thing about all these different implementations is that when Walter chooses one (you ARE going to put one in the standard library, right?), he'll have a wide selection to make his choice from.

And when he picks one, we can all bitch endlessly about it here ^_^

Ah well.  I think I'll go work on short form now... must... dethrone... other... implementations...

	-- Daniel

jcc7 wrote:
> In article <e1ocf1$2iej$1@digitaldaemon.com>, Daniel Keep says...
>> This is a multi-part message in MIME format.
>> --------------090201060608040605000801
>> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit
>>
>> Me again :P
>>
>> I found I needed something to dump a file as hex the other day, so naturally the first thing I wrote was a command-line argument parser :P
>>
>> Here's the preliminary version, and since I can't see anything similar in either phobos or on dsource, I thought I'd post it up here to see if anyone thinks I should try getting it online somewhere.
> 
> Something like really needs to be added to Phobos since it's such a popular idea. I created a wiki page to list the existing modules (including this newest one): http://www.prowiki.org/wiki4d/wiki.cgi?Phobos/PosixGetOpt
> 
> jcc7

-- 

v1sw5+8Yhw5ln4+5pr6OFma8u6+7Lw4Tm6+7l6+7D a2Xs3MSr2e4/6+7t4TNSMb6HTOp5en5g6RAHCP    http://hackerkey.com/
April 14, 2006
In article <e1op4c$2ueu$1@digitaldaemon.com>, Daniel Keep says...
>
>Yup.  Definitely need to learn to look better :P

Well, I remembered where the one I found was, so it wasn't a fair fight.

>In all honesty, I never liked getopt.  Too fiddly for my tastes.  I suppose in the end, the good thing about all these different implementations is that when Walter chooses one (you ARE going to put one in the standard library, right?), he'll have a wide selection to make his choice from.

That's right.

>And when he picks one, we can all bitch endlessly about it here ^_^

Maybe he'll be generous and let us have two (yeah, right).

jcc7
April 14, 2006
Daniel Keep wrote:

> 
> Frank Benoit wrote:
>> Or this one
>> 
>> http://svn.dsource.org/projects/ddl/trunk/utils/ArgParser.d
> 
> That one's pretty nice; much shorter than mine.
> 
> But then, mine produces a hash of boxes of pre-formatted values.  With that one, you have to write a new delegate for each option.

Hmm, I'm not totally sure I understand what you mean, could you provide an example?

> 
> Plus, it doesn't have the way, way cool OptionParser.showHelp() method
> ^_^.

Does it print the arguments handled by optparse, like a default help sortof?

ArgParser is only meant to be a low level arg/opt parser. I also think it should be easy to extend, both internally, and on top of it.

« First   ‹ Prev
1 2