optparse module

Daniel Keep daniel.keep.lists at gmail.com
Fri Apr 14 11:14:19 PDT 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/



More information about the Digitalmars-d mailing list