www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.announce - optparse.d -- good enough to be std.optparse?

reply derick_eddington nospam.yashmoo.com writes:
I've made a command-line option helper similar to Python's optparse.  It allows
you to specify what D-type you want the option as, short name, long name, help,
and more.  It automatically creates a formatted help message and prints it on
errors.  It checks that clients' usage of the module is proper; and it checks
that the command-line arguments meet what was specified.  It has a compehensive
unittest that demonstrates more.  The source is attached.

: /**
:  * Example usage:
:  */
: int main (char[][] args)
: {
:     int verbosity;
:     char[] outfile;
:     char[][] files;
:
:     // Constructor parameters are used in printing help.
:     // -h / --help is always added by default
:     // and uses program-name and usage.
:     // --version (no short name) is added by
:     // default if version is given.
:     //                                   program-name
:     OptionParser op = new OptionParser(__FILE__[0..$-2],
:     //                 usage                version
:         "[options] --files=f1,fN [outfile]", "0.2");
:
:     // int, short and long, help, metavar,
:     // no default, not mandatory
:     op.addOption!(int)("v", "verbose",
:         "Be more and more and more and more and more "
:         "and more and more verbose.", "LEVEL");
:     // comma-separated string list, short and long, help,
:     // metavar, no default, mandatory
:     op.addOption!(char[][])("fs", "files",
:         "Files to process, and make this a really long help "
:         "string as well to test aligning.", "FILE,FILE,...",
:         null, true);
:     // float, long-only, help, metavar, default, not mandatory
:     op.addOption!(float)(null, "thing", "Do it with this.",
:         "FLOAT", -4.297e21f);
:     // no-value, short-only, with help, no metavar,
:     // no default, not mandatory
:     op.addOption!()("a", null, "Use alternate method.");
:
:     // Parse command-line arguments, including args[0]
:     // program-name (it's skipped).
:     // args will be reset to the remaining non-option
:     // command-line arguments in the order they appeared.
:     Options options = op.parse(args);
:
:     // Check if option was given on the command-line
:     // by using (char[] in Options).
:     // If the option has both short and long names,
:     // either can be used.
:     if ("verbose" in options)
:         // If option was given and it has a value,
:         // retrieve it by indexing Options with short
:         // or long name (or only one if only one)
:         // and do getValue!(T)
:         verbosity = options["verbose"].getValue!(int);
:
:     if (verbosity > 0)
:         writefln("I'll say a little.");
:     if (verbosity > 1)
:         writefln("I'll say a lot more.");
:
:     // args was reset by parse to the remaining
:     // non-option command-line arguments
:     if (args.length == 1)
:         // use the first non-option argument
:         outfile = args[0];
:     else if (args.length > 1)
:         // OptionError.errorExit("message") can be used to
:         // print help and exit process;
:         // useful when checking non-option arguments
:         op.errorExit("more than one output file specified");
:
:     // mandatory options can be assumed to be
:     // there after successful parse
:     assert ("files" in options);
:     files = options["files"].getValue!(char[][]);
:     if (files.length == 0)
:         op.errorExit("need to specifiy at least one input file");
:
:     if (verbosity > 0)
:     {
:         if ("thing" in options)
:             writefln("my thing is: ",
:                 options["thing"].getValue!(float));
:
:         // no-value options are simply tested for being in Options
:         if ("a" in options)
:             writefln("I would process files using alternate method:");
:         else
:             writefln("I would process files using normal method:");
:         foreach (char[] f; files)
:             writefln("\t",f);
:         writefln("and output to ",
:             outfile.length ? outfile : "<stdout>");
:     }
:
:     return 0;
: }

Example command-line output of above program:

---------------------------------------------------------------

$ ./example -h
usage:  optparse [options] --files=f1,fN [outfile]

options:
-h, --help            Show this help message and exit.
--version             Show program's version number and exit.
-vLEVEL, --verbose=LEVEL
Be more and more and more and more and more and more
and more verbose.
-fsFILE,FILE,..., --files=FILE,FILE,...
Files to process, and make this a really long help
string as well to test aligning.
--thing=FLOAT         Do it with this.
-a                    Use alternate method.

---------------------------------------------------------------

$ ./example -v2 --files=somefile,anotherfile,nextfile --thing -4.23e-6 -a
outputfile
I'll say a little.
I'll say a lot more.
my thing is: -4.23e-06
I would process files using alternate method:
somefile
anotherfile
nextfile
and output to outputfile

---------------------------------------------------------------

$ ./example --asdf
optparse: error: no such option: --asdf

[help]

---------------------------------------------------------------

$ ./example
optparse: error: -fs / --files option is mandatory

[help]



begin 0644 optparse.d

M*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ
M*BHJ*BHJ* T*("H 0GD 1&5R:6-K($5D9&EN9W1O;BX 4&QA8V5D(&EN('1H
M92!P=6)L:6, 9&]M86EN+B` ("` ("` ("` ("` ("` ("` ("` ("H-"B`J
M($EN<W!I<F5D(&)Y(%!Y=&AO;B=S(&]P='!A<G-E+B` ("` ("` ("` ("` 

M("` ("` ("` ("` ("` ("` ("` ("` ("` ("` ("` ("` ("` ("` ("` 
M("` ("` ("` ("` ("` ("` * T*("H 4V5E(&)O='1O;2!O9B!T:&ES(&9I
M;&4 9F]R(&5X86UP;&4 =7-A9V4N("` ("` ("` ("` ("` ("` ("` ("` 
M("` ("` ("H-"B`J*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ
M*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ+PT*



M=&0N<W1D87)G+`T*("` ("` ("` ("` ("` <W1D+G-T9&EO+`T*("` ("` 

M97,-"GL-" E.;U9A;'5E+`T*"4EN="P-" E);G1!<G)A>2P-"B\K('5I;G0 
M:7, 8V%U<VEN9R!S;VUE($1-1"!B=6<N+BX-" E526YT+`T*"55);G1!<G)A






M:69T>7!E("A4(#H :6YT*2` ("` ("![(')E='5R;B!3=7!P;W)T9614>7!E
M<RY);G0[('T-" D)96QS92!I9G1Y<&4 *%0 .B!I;G1;72D ("` ('L <F5T


M="D ("` ("` >R!R971U<FX 4W5P<&]R=&5D5'EP97,N54EN=#L ?0T*"0EE
M;'-E(&EF='EP92`H5"`Z('5I;G1;72D ("` ('L <F5T=7)N(%-U<'!O<G1E


M"65L<V4 :69T>7!E("A4(#H ;&]N9UM=*2` ("` >R!R971U<FX 4W5P<&]R


M"65L<V4 :69T>7!E("A4(#H =6QO;F=;72D ("` ('L <F5T=7)N(%-U<'!O
M<G1E9%1Y<&5S+E5,;VYG07)R87D[('TK+PT*"0EE;'-E(&EF='EP92`H5"`Z
M(&9L;V%T*2` ("` >R!R971U<FX 4W5P<&]R=&5D5'EP97,N1FQO870[('T-
M" D)96QS92!I9G1Y<&4 *%0 .B!F;&]A=%M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86YD871O<GD =VEL;"!H879E(&YO(&5F9F5C
M="X ($EF(&1E9F%U;'1686QU92!I<PT*"2`J(&YU;&PL(&ET(&UE86YS(&YO
M(&1E9F%U;'0 =F%L=64N("!D969A=6QT5F%L=64 ;75S="!B92!N=6QL(&9O
M<B!N;RUV86QU90T*"2`J(&]P=&EO;G, =&AA="!N965D('1O('-P96-I9FEY
M(&UA;F1A=&]R>2X-" D *B\-" ET96UP;&%T92!A9&1/<'1I;VX *%0 /2!.
M;U9A;'5E*0T*"7L-" EV;VED(&%D9$]P=&EO;B`H8VAA<EM=('-H;W)T3F%M
M92P 8VAA<EM=(&QO;F=.86UE(#T ;G5L;"P 8VAA<EM=(&AE;'` /2!N=6QL

M="`H<VAO<G1.86UE+FQE;F=T:"!\?"!L;VYG3F%M92YL96YG=& I.PT*"0EA
M<W-E<G0 *%]A<F=U;65N=',N;&5N9W1H(#P

M" D)9F]R96%C:"`H0F%S94]P=&EO;B!O.R!F:6YD3W!T:6]N<RD >PT*"0D)
M:68 *'-H;W)T3F%M92YL96YG=&  )B8 <VAO<G1.86UE(#T](&\N<VAO<G1.
M86UE*0T*"0D)"71H<F]W(&YE=R!/<'1087)S945R<F]R*")C;VYF;&EC=&EN
M9R!O<'1I;VXZ("TB('X <VAO<G1.86UE*3L-" D)"6EF("AL;VYG3F%M92YL
M96YG=&  )B8 ;&]N9TYA;64 /3T ;RYL;VYG3F%M92D-" D)"0ET:')O=R!N
M97< 3W!T4&%R<V5%<G)O<B B8V]N9FQI8W1I;F< ;W!T:6]N.B`M+2( ?B!L

M<'1I;VXA*%0I*'-H;W)T3F%M92P ;&]N9TYA;64L(&AE;'`L(&UE=&%687(I



M"0DO+R!N965D960 =&\ 861V86YC92!?87)G<'1R(&)E8V%U<V4 ;6%N9&%T

M('9A7V%R9R$H='EP96]F*&YU;&PI*2A?87)G<'1R*3L-" D)"0EI9B`H7V%R
M9W5M96YT<ULP72`A/2!T>7!E:60H='EP96]F*&YU;&PI*2!\?"!I9VYO<F4 
M(3T ;G5L;"D-" D)"0D)=&AR;W< ;F5W($]P=%!A<G-E17)R;W(H9F]R;6%T
M*"(E<R!O<'1I;VX :&%S(&YO('9A;'5E+"!D969A=6QT('9A;'5E(&UU<W0 
M8F4 ;G5L;"!W:&5N('-P96-I9FEY:6YG(&UA;F1A=&]R>2(L(&]P=&EO;BDI

M=&AR;W< ;F5W($]P=%!A<G-E17)R;W(H9F]R;6%T*"(E<R!O<'1I;VX :&%S
M(&YO('9A;'5E+"!S;R!N;R!D969A=6QT('9A;'5E(&-A;B!B92!S<&5C:69I
M960B+"!O<'1I;VXI*3L-" D)?0T*"0EE;'-E('L-" D)"6EF("A?87)G=6UE
M;G1S+FQE;F=T:"D >PT*"0D)"6EF("A?87)G=6UE;G1S6S!=("$]('1Y<&5I

M('1Y<&5I9"A4*2D-" D)"0D)"71H<F]W(&YE=R!/<'1087)S945R<F]R*&9O
M<FUA=" B)7, ;W!T:6]N)W, 9&5F875L="!V86QU92!N;W0 ='EP92`E<RP 
M:7, ='EP92`E<R(L(&]P=&EO;BP ='EP96ED*%0I+"!?87)G=6UE;G1S6S!=


M9F%U;'1686QU94]P=&EO;G-;;W!T:6]N+G-H;W)T3F%M95T /2!O<'1I;VX[

M875L=%9A;'5E3W!T:6]N<UMO<'1I;VXN;&]N9TYA;65=(#T ;W!T:6]N.PT*
M"0D)"0DO+V1E8G5G('=R:71E9FQN*")<=&1E9F%U;'0 =F%L=64 /2`E<R(L

M=',N;&5N9W1H(#X ,2D >PT*"0D)"0DO+R!N965D960 =&\ 861V86YC92!?
M87)G<'1R(&EN8V%S92!M86YD871O<GD :7, ;F5X="!V87)A<F<-" D)"0D)
M='EP96]F*&YU;&PI(&EG;F]R92`]('9A7V%R9R$H='EP96]F*&YU;&PI*2A?

M;&5N9W1H(#X ,2D >PT*"0D):68 *%]A<F=U;65N='-;,5T (3T ='EP96ED
M*&)O;VPI*0T*"0D)"71H<F]W(&YE=R!/<'1087)S945R<F]R*&9O<FUA=" B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86-H("A"87-E3W!T:6]N(&\[(&9I;F1/<'1I;VYS

M"0D)"69O<F5A8V  *$)A<V5/<'1I;VX 9F\[(&9O=6YD3W!T:6]N<RD-" D)

M*"%F;W5N9"D-" D)"0D)=&AR;W< ;F5W($]P=&EO;D5R<F]R*&9O<FUA=" B


M" T*"0ED96)U9R!W<FET969L;B B)7,N<&%R<V4H*2!D;VYE+B(L('1H:7,I
M.PT*"0EA<F=S(#T ;&5F=&]V97)!<F=S.PT*"0ER971U<FX 9F]U;F1/<'1I



M"6-H87);72!A;&EG;D]P=$AE;'!3='( *&-H87);72!H+"!S:7IE7W0 ;VAL

M(EQN(CL-" D)"0EC:&%R6UT :6YD96YT(#T





M"0D)"6EF("AL:6YE+FQE;F=T:"D-" D)"0D);&EN97, ?CT ;&EN93L-" D)
M"0EF;W)E86-H("AC:&%R6UT ;#L





M" D):68 *&9I;F1/<'1I;VYS+FQE;F=T:"D-" D)"6AE;'` ?CT (EQN7&YO
M<'1I;VYS.EQN(CL-" T*"0EF;W)E86-H("A"87-E3W!T:6]N(&\[(&9I;F1/


M+G-H;W)T3F%M93L-" D)"0EI9B`H;RYM971A5F%R+FQE;F=T:"D-" D)"0D)


M;VYG3F%M92YL96YG=& I('L-" D)"0EO<'1(96QP('X]("(M+2( ?B!O+FQO
M;F=.86UE.PT*"0D)"6EF("AO+FUE=&%687(N;&5N9W1H*0T*"0D)"0EO<'1(
M96QP('X]("(](B!^(&\N;65T859A<CL-" D)"7T-" D)"6EF("AO+FAE;'`N
M;&5N9W1H*0T*"0D)"6]P=$AE;'` ?CT 86QI9VY/<'1(96QP4W1R*&\N:&5L
M<"P ;W!T2&5L<"YL96YG=& I.PT*"0D):&5L<"!^/2!O<'1(96QP('X (EQN

M5F5R<VEO;B`H*0T*"7L-" D)=W)I=&5F;&XH(B5S("5S(BP <')O9TYA;64L

M>PT*"0EW<FET969L;B B)7,Z(&5R<F]R.B`E<UQN(BP <')O9TYA;64L(&US

M=&4 =&5M<&QA=&4 <&%R<V5!<G)A>2`H5"D >PT*"51;72!P87)S94%R<F%Y
M("AC:&%R6UT =G,L(%0 9G5N8W1I;VX *&-H87);72D <&%R<V54*0T*"7L-
M" D)9&5B=6< =W)I=&5F;&XH(B5S+G!A<G-E07)R87DA*"5S*2AV<SU<(B5S
M7"( <&%R<V54/25S*2(L('1H:7,L('1Y<&5I9"A4*2P =G,L('!A<G-E5"D[

M"69O<F5A8V  *&-H87);72!S.R!S<RD-" D)"6EF("AS+FQE;F=T:"D-" D)


M("H 26YT96YD960 =&\ 8F4 =7-E9"!S;VUE=&AI;F< ;&EK93H-"B`J(&EF
M(" B;W!T:6]N(B!I;B!O<'1I;VYS*0T*("H ("` (%0 8FQA:"`](&]P=&EO
M;G-;(F]P=&EO;B)=+F=E=%9A;'5E(2A4*3L-"B`J+PT*='EP961E9B!"87-E



M<&QE;65N=', ;65M8F5R<R!C;VUM;VX =&\ 86QL(&]P=&EO;G, 86YD('!R
M;W9I9&5S('1E;7!L871E(&9O< T*("H <F5T<FEE=FEN9R!O<'1I;VX =F%L

M8W0 8VQA<W, 0F%S94]P=&EO; T*>PT*"6-H87);72!S:&]R=$YA;64L(&QO
M;F=.86UE.PT*"6-H87);72!H96QP+"!M971A5F%R.PT*"6)O;VP ;6%N9&%T

M;R!?='EP93L-" T*"71H:7, *%-U<'!O<G1E9%1Y<&5S('0L(%1Y<&5);F9O
M('1I+"!C:&%R6UT <TYA;64L(&-H87);72!L3F%M92P 8VAA<EM=(& L(&-H
M87);72!M5F%R*0T*"6EN('L-" D)87-S97)T("AS3F%M92YL96YG=&  ?'P 

M='EP92`]('1I.PT*"0ES:&]R=$YA;64 /2!S3F%M93L-" D);&]N9TYA;64 

M96)U9R!W<FET969L;B B)7,N=&AI<R I(&1O;F4 +2T 7W1Y<&4 /2`E<R(L

M*2`M+2!2971U<FYS('1H:7, ;W!T:6]N)W, =F%L=64 87, =&AE(&-O<G)E
M8W0 ='EP92X-" D *B` ("` ("` ("` ("` ("` ("!)9B!T:&4 =W)O;F< 
M='EP92!I<R!A='1E;7!T960L($]P=%!A<G-E17)R;W( :7, =&AR;W=N+ T*
M"2`J+PT*"71E;7!L871E(&=E=%9A;'5E("A4*0T*"7L-" E4(&=E=%9A;'5E

M*0T*"0D)=&AR;W< ;F5W($]P=%!A<G-E17)R;W(H9F]R;6%T*"(E<R!O<'1I
M;VX 9&]E<R!N;W0 :&%V92!A('9A;'5E('1O(')E=')I979E(BP =&AI<RDI

M=&AR;W< ;F5W($]P=%!A<G-E17)R;W(H9F]R;6%T*"(E<R!O<'1I;VX ;75S
M="!B92!R971R:65V960 87, ='EP92`E<RP ;F]T('1Y<&4 )7,B+"!T:&ES


M<BAF;W)M870H(B5S(&]P=&EO;B!C86X ;F]T(&)E(')E=')I979E9"!A<R!U




M:&%R6UT ;W!T5&]3=')I;F< *&-H87);72!S:&]R=$YA;64L(&-H87);72!L
M;VYG3F%M92D-"GL-" ER971U<FX *'-H;W)T3F%M92YL96YG=&  /R`B+2)^
M<VAO<G1.86UE(#H (B(I('X *"AS:&]R=$YA;64N;&5N9W1H("8F(&QO;F=.
M86UE+FQE;F=T:"D /R`B("\ (B`Z("(B*2!^("AL;VYG3F%M92YL96YG=&  
M/R`B+2TB?FQO;F=.86UE(#H
M86YD+6QI;F4 ;W!T:6]N+B` 4&%R86UE=&5R:7IE9"!B>2!A('1Y<&4 =&\ 
M<W!E8VEF:7D 82!V86QU90T*("H :7, 97AP96-T960 86YD('=H870 ='EP
M92P ;W( 3F]686QU92!T;R!M96%N('1H92!O<'1I;VX 9&]E<R!N;W0-"B`J



M92P 8VAA<EM=(&QO;F=.86UE+"!C:&%R6UT :&5L<"P 8VAA<EM=(&UE=&%6

M5"DL('-H;W)T3F%M92P ;&]N9TYA;64L(&AE;'`L(&UE=&%687(I.PT*"0E]

M:')O=R!N97< 3W!T4&%R<V5%<G)O<BAF;W)M870H(B5S(&]P=&EO;B!C86X 
M;F]T(&)E('5N<W5P<&]R=&5D('1Y<&4 )7,B+"!O<'14;U-T<FEN9RAS:&]R
M=$YA;64L;&]N9TYA;64I+"!U<W1E+G1Y<&4I*3L-" D)?0T*"7T-"GT-" T*

M=&5S="(L(%]?1DE,15]?*3L-" T*"4]P=&EO;E!A<G-E<B!O<'1I;VY087)S



M;VY087)S97(H7U]&24Q%7U];,"XN)"TR72P (EMO<'1I;VX 6W9A;'5E75TB



M<BYA9&1/<'1I;VXA*&EN="DH(G B+")X96YO(BPB9&]E<R!T:&ES(&%N9"!T

M*&-H87);72DH;G5L;"PB8F%R(BPB;6%K92!I="!H87!P96XB+")"3$]"(BPB
M9&5F875L="UV86QU92(I.PT*"0EO<'1I;VY087)S97(N861D3W!T:6]N(2AI

M"6]P=&EO;E!A<G-E<BYA9&1/<'1I;VXA*&-H87);75M=*2 B<V(B+")S:&%B

M4&%R<V5R+F%D9$]P=&EO;B$H*2 I.PT*"0ED96)U9R!W<FET969L;B B+2TM
M(&YE=R!/<'1I;VY087)S97(G<R!H96QP("TM+2(I.PT*"0ED96)U9R!O<'1I

M96YD("TM+2(I.PT*"7T-" T*"6YE=T]P=&EO;E!A<G-E<B I.PT*"6%R9W, 


M87-D9B(I.PT*"4]P=&EO;G, ;W!T:6]N<R`](&]P=&EO;E!A<G-E<BYP87)S
M92AA<F=S*3L-" ES=&%T:6, 8VAA<EM=6UT ;&5F=&]V97( /2!;(FQA;&$B
M+")H;VAO(BPB87-D9B)=.PT*"6%S<V5R="`H87)G<R`]/2!L969T;W9E<BD[


M86QU92$H9FQO870I(#T](#DX-RXV-68I.PT*"6%S<V5R="`H(F)A<B( :6X 

M8VAA<EM=*2`]/2`B8F%R+7-T<FEN9R(I.PT*"6%S<V5R="`H(F%P<&QE(B!I



M871I8R!C:&%R6UU;72!S:&%B86YG0T%!(#T 6R)A8F,B+")D(BPB968B+")Z
M>GIZ>GHB73L-" EA<W-E<G0 *&]P=&EO;G-;(G-H86)A;F<B72YG971686QU
M92$H8VAA<EM=6UTI(#T
M*")M>6%P<"`M+79E<F)O<V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DB*3L-" DO+V]P=&EO;G, /2!O<'1I;VY0



M<F)O<V4B72YG971686QU92$H:6YT*3L-" DO+V%S<V5R="`H9F%I;',H9&5L
M96=A=&4 =F]I9"`H*2![(&]P=&EO;G-;(G9E<F)O<V4B72YG971686QU92$H
M8F]O;"D[('TI*3L ("\O(&-A=7-E<R!$340 8G5G($D 8V%N)W0 <F5P<F]D
M=6-E('-I;7!L97(L(&EF(&)O;VP 8B`]('-T871M96YT(&ES(&1O;F4L(&ET




M<&QE('5S86=E+ T*"2`J+PT*"6EN="!M86EN("AC:&%R6UU;72!A<F=S*0T*


M960 :6X <')I;G1I;F< :&5L<`T*"0DO+R!O<'1I;VX +6  +R`M+6AE;'` 
M:7, 86QW87ES(&%D9&5D(&)Y(&1E9F%U;'0 86YD('5S97, <')O9W)A;2UN
M86UE(&%N9"!U<V%G90T*"0DO+R!O<'1I;VX +2UV97)S:6]N("AN;R!S:&]R
M="!N86UE*2!I<R!A9&1E9"!B>2!D969A=6QT(&EF('9E<G-I;VX :7, 9VEV
M96X-" D)+R\ ("` ("` ("` ("` ("` ("` ("` ("` ("` ("` ("` ('!R
M;V=R86TM;F%M92` ("` ("` ("` ("` ('5S86=E("` ("` ("` ("` ("` 
M('9E<G-I;VX-" D)3W!T:6]N4&%R<V5R(&]P(#T ;F5W($]P=&EO;E!A<G-E
M<BA?7T9)3$5?7ULP+BXD+3)=+"`B6V]P=&EO;G-=("TM9FEL97,]9C$L9DX 

M;F<L(&AE;'`L(&UE=&%V87(L(&YO(&1E9F%U;'0L(&YO="!M86YD871O<GD-
M" D);W`N861D3W!T:6]N(2AI;G0I*")V(BP (G9E<F)O<V4B+"`B0F4 ;6]R
M92!A;F0 ;6]R92!A;F0 ;6]R92!A;F0 ;6]R92!A;F0 ;6]R92!A;F0 ;6]R
M92!A;F0 ;6]R92!V97)B;W-E+B(L("),159%3"(I.PT*"0DO+R!C;VUM82US
M97!A<F%T960 <W1R:6YG(&QI<W0L('-H;W)T(&%N9"!L;VY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D)"7=R:71E9FQN

M:6QE+FQE;F=T:"`_(&]U=&9I;&4 .B`B/'-T9&]U=#XB
3"7)E='5R;B`P.PT*"7T-"GT-"F4 
`
end
May 30 2005
next sibling parent derick_eddington nospam.yashmoo.com writes:
In article <d7g5nd$3i3$1 digitaldaemon.com>, derick_eddington nospam.yashmoo.com
says...
Example command-line output of above program:

---------------------------------------------------------------

$ ./example -h
usage:  optparse [options] --files=f1,fN [outfile]

options:
-h, --help            Show this help message and exit.
--version             Show program's version number and exit.
-vLEVEL, --verbose=LEVEL
Be more and more and more and more and more and more
and more verbose.
-fsFILE,FILE,..., --files=FILE,FILE,...
Files to process, and make this a really long help
string as well to test aligning.
--thing=FLOAT         Do it with this.
-a                    Use alternate method.
Arg, forgot to : these. The help print is nicely formatted...
May 30 2005
prev sibling next sibling parent reply "Kris" <fu bar.com> writes:
Very useful. I'd like to add this to Mango, if that would be OK?

- Kris

<derick_eddington nospam.yashmoo.com> wrote in message
news:d7g5nd$3i3$1 digitaldaemon.com...
 I've made a command-line option helper similar to Python's optparse.  It
allows
 you to specify what D-type you want the option as, short name, long name,
help,
 and more.  It automatically creates a formatted help message and prints it
on
 errors.  It checks that clients' usage of the module is proper; and it
checks
 that the command-line arguments meet what was specified.  It has a
compehensive
 unittest that demonstrates more.  The source is attached.

 : /**
 :  * Example usage:
 :  */
 : int main (char[][] args)
 : {
 :     int verbosity;
 :     char[] outfile;
 :     char[][] files;
 :
 :     // Constructor parameters are used in printing help.
 :     // -h / --help is always added by default
 :     // and uses program-name and usage.
 :     // --version (no short name) is added by
 :     // default if version is given.
 :     //                                   program-name
 :     OptionParser op = new OptionParser(__FILE__[0..$-2],
 :     //                 usage                version
 :         "[options] --files=f1,fN [outfile]", "0.2");
 :
 :     // int, short and long, help, metavar,
 :     // no default, not mandatory
 :     op.addOption!(int)("v", "verbose",
 :         "Be more and more and more and more and more "
 :         "and more and more verbose.", "LEVEL");
 :     // comma-separated string list, short and long, help,
 :     // metavar, no default, mandatory
 :     op.addOption!(char[][])("fs", "files",
 :         "Files to process, and make this a really long help "
 :         "string as well to test aligning.", "FILE,FILE,...",
 :         null, true);
 :     // float, long-only, help, metavar, default, not mandatory
 :     op.addOption!(float)(null, "thing", "Do it with this.",
 :         "FLOAT", -4.297e21f);
 :     // no-value, short-only, with help, no metavar,
 :     // no default, not mandatory
 :     op.addOption!()("a", null, "Use alternate method.");
 :
 :     // Parse command-line arguments, including args[0]
 :     // program-name (it's skipped).
 :     // args will be reset to the remaining non-option
 :     // command-line arguments in the order they appeared.
 :     Options options = op.parse(args);
 :
 :     // Check if option was given on the command-line
 :     // by using (char[] in Options).
 :     // If the option has both short and long names,
 :     // either can be used.
 :     if ("verbose" in options)
 :         // If option was given and it has a value,
 :         // retrieve it by indexing Options with short
 :         // or long name (or only one if only one)
 :         // and do getValue!(T)
 :         verbosity = options["verbose"].getValue!(int);
 :
 :     if (verbosity > 0)
 :         writefln("I'll say a little.");
 :     if (verbosity > 1)
 :         writefln("I'll say a lot more.");
 :
 :     // args was reset by parse to the remaining
 :     // non-option command-line arguments
 :     if (args.length == 1)
 :         // use the first non-option argument
 :         outfile = args[0];
 :     else if (args.length > 1)
 :         // OptionError.errorExit("message") can be used to
 :         // print help and exit process;
 :         // useful when checking non-option arguments
 :         op.errorExit("more than one output file specified");
 :
 :     // mandatory options can be assumed to be
 :     // there after successful parse
 :     assert ("files" in options);
 :     files = options["files"].getValue!(char[][]);
 :     if (files.length == 0)
 :         op.errorExit("need to specifiy at least one input file");
 :
 :     if (verbosity > 0)
 :     {
 :         if ("thing" in options)
 :             writefln("my thing is: ",
 :                 options["thing"].getValue!(float));
 :
 :         // no-value options are simply tested for being in Options
 :         if ("a" in options)
 :             writefln("I would process files using alternate method:");
 :         else
 :             writefln("I would process files using normal method:");
 :         foreach (char[] f; files)
 :             writefln("\t",f);
 :         writefln("and output to ",
 :             outfile.length ? outfile : "<stdout>");
 :     }
 :
 :     return 0;
 : }

 Example command-line output of above program:

 ---------------------------------------------------------------

 $ ./example -h
 usage:  optparse [options] --files=f1,fN [outfile]

 options:
 -h, --help            Show this help message and exit.
 --version             Show program's version number and exit.
 -vLEVEL, --verbose=LEVEL
 Be more and more and more and more and more and more
 and more verbose.
 -fsFILE,FILE,..., --files=FILE,FILE,...
 Files to process, and make this a really long help
 string as well to test aligning.
 --thing=FLOAT         Do it with this.
 -a                    Use alternate method.

 ---------------------------------------------------------------

 $ ./example -v2 --files=somefile,anotherfile,nextfile --thing -4.23e-6 -a
 outputfile
 I'll say a little.
 I'll say a lot more.
 my thing is: -4.23e-06
 I would process files using alternate method:
 somefile
 anotherfile
 nextfile
 and output to outputfile

 ---------------------------------------------------------------

 $ ./example --asdf
 optparse: error: no such option: --asdf

 [help]

 ---------------------------------------------------------------

 $ ./example
 optparse: error: -fs / --files option is mandatory

 [help]
May 30 2005
parent reply derick_eddington nospam.yashmoo.com writes:
Certainly.  I'll keep you updated as I enhance and fix bugs.

In article <d7g9q7$7b3$1 digitaldaemon.com>, Kris says...
Very useful. I'd like to add this to Mango, if that would be OK?

- Kris

<derick_eddington nospam.yashmoo.com> wrote in message
news:d7g5nd$3i3$1 digitaldaemon.com...
 I've made a command-line option helper similar to Python's optparse.  It
allows
 you to specify what D-type you want the option as, short name, long name,
help,
 and more.  It automatically creates a formatted help message and prints it
on
 errors.  It checks that clients' usage of the module is proper; and it
checks
 that the command-line arguments meet what was specified.  It has a
compehensive
 unittest that demonstrates more.  The source is attached.
May 30 2005
parent reply kris <fu bar.org> writes:
derick_eddington nospam.yashmoo.com wrote:
 Certainly.  I'll keep you updated as I enhance and fix bugs.
Excellent ~ thx!
May 30 2005
next sibling parent James Dunne <james.jdunne gmail.com> writes:
In article <d7gqjo$nth$2 digitaldaemon.com>, kris says...
derick_eddington nospam.yashmoo.com wrote:
 Certainly.  I'll keep you updated as I enhance and fix bugs.
Who doesn't love to enhance bugs? =P
Excellent ~ thx!
Regards, James Dunne
May 31 2005
prev sibling parent derick_eddington nospam.yashmoo.com writes:
I've updated optparse.d:

Option groups for help printout.
Example:

: optionParser = new OptionParser("myapp", "[option [value]]");
: optionParser.addOption!()("v", "verbose");
: optionParser.addOption!(float)("f", "foo", null, null, null, true);
: optionParser.addOption!(int)("x", "xeno", "does this and that", "THING");
: optionParser.addOption!(int[])("a", "apple", "make applesauce", null);
: optionParser.addOption!(long)("l", "long", "be longer", "LONG");
: optionParser.addOption!(double)("d", "double", null, "DOUBLE");
: optionParser.addOption!(uint[])("ui", "uint", null, "UINT,...");
: // make a group, options must have previously been added
: optionParser.makeGroup("number options", "f", "x", "a", "l", "d", "ui");
: optionParser.addOption!(char[])(null, "bar", "make it happen", "BLOB");
: optionParser.addOption!(char[][])("sb", "shabang", "blow up", "IT");
: // make a group, options must have previously been added
: optionParser.makeGroup("string options", "bar", "sb");

Will make help:

: usage:  myapp [option [value]]
:
: options:
:   -h, --help            Show this help message and exit.
:   --version             Show program's version number and exit.
:   -v, --verbose
:
: number options:
:   -f, --foo
:   -x THING, --xeno=THING
:                         does this and that
:   -a, --apple           make applesauce
:   -l LONG, --long=LONG
:                         be longer
:   -d DOUBLE, --double=DOUBLE
:   -ui UINT,..., --uint=UINT,...
:
: string options:
:   --bar=BLOB            make it happen
:   -sb IT, --shabang=IT
:                         blow up

Help string formatting separates short-name from METAVAR by a space for easier
reading.

Smarter use of templates to support more types.

Bug *un-enhanced* :) where "--option= --next-opt" would consume --next-opt as
--option's value instead of causing error because --option has no value.

A few more unittest cases.

Question for potential users of optparse.d:
Would you rather have anal checking of all usage of the module or reduce the
object-file size from 55k to 35k? I tried to use "version" but it's too buggy (I
just wanted version'd else-if...)

--Derick


begin 0644 optparse.d

M*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ*BHJ
M*BHJ*BHJ* T*("H 0GD 1&5R:6-K($5D9&EN9W1O;BX 4&QA8V5D(&EN('1H
M92!P=6)L:6, 9&]M86EN+B` ("` ("` ("` ("` ("` ("` ("`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<&]G871E

M;W( .B!%<G)O< T*>PT*"71H:7, *&-H87);72!M<V<I("![('-U<&5R*&US

M;6]D=6QE+B` 0V]N<W1R=6-T(&ET('=I=&  >6]U<B!P<F]G<F%M)W, ;F%M
M90T*("H 86YD(&]P=&EO;F%L;'D 82!U<V%G92!M97-S86=E(&%N9"!V97)S


M87-S($]P=&EO;E!A<G-E< T*>PT*"7!R:79A=&4 8VAA<EM=('!R;V=.86UE
M+"!U<V%G92P =F5R.PT*"7!R:79A=&4 0F%S94]P=&EO;EM=(&9I;F1/<'1I
M;VYS.PT*"7!R:79A=&4 3W!T:6]N<R!D969A=6QT5F%L=65/<'1I;VYS.PT*

M("AC:&%R6UT <')O9TYA;64L(&-H87);72!U<V%G92`](&YU;&PL(&-H87);
M72!V97( /2!N=6QL*0T*"6EN('L-" D)87-S97)T("AP<F]G3F%M92YL96YG
M=& I.PT*"7T-" EB;V1Y('L-" D)=&AI<RYP<F]G3F%M92`]('!R;V=.86UE
M.PT*"0ET:&ES+G5S86=E(#T
M"0EO<'1I;VY'<F]U<', ?CT ;F5W($]P=&EO;D=R;W5P*")O<'1I;VYS(BD[


M861D3W!T:6]N(2 I*&YU;&PL(")V97)S:6]N(BP (E-H;W< <')O9W)A;2=S
M('9E<G-I;VX ;G5M8F5R(&%N9"!E>&ET+B(I.PT*"7T-" T*"6EN=F%R:6%N
M=`T*"7L-" D)87-S97)T("AO<'1I;VY'<F]U<',N;&5N9W1H*3L-" D)87-S
M97)T("AO<'1I;VY'<F]U<'-;,%T (3T](&YU;&PI.PT*"7T-" T*"2\J* T*
M"2`J(%5S92!W:71H;W5T(&$ ='EP92!F;W( 82!N;RUV86QU92]T;V=G;&4 

M('1Y<&5S('1O(')E=')I979E('1H92!O<'1I;VXG<R!V86QU92!A<R!T:&%T
M($0M='EP92X ($]N92!O9 T*"2`J('-H;W)T3F%M92!O<B!L;VYG3F%M92!M
M=7-T(&)E('-P96-I9FEE9"P ;W( 8F]T:"X (&AE;'` :7, =&AE(&AE;'` 
M;65S<V%G90T*"2`J(&9O<B!T:&4 ;W!T:6]N+"!P<FEN=&5D('=H96X =&AE

M82!D97-C:7!T:79E(&YA;64 9F]R('1H92!O<'1I;VXG<R!V86QU92!U<V5D

M<F%R9W, :7, =&\ 86QL;W< )U0 9&5F875L=%9A;'5E)R!A;F0 )V)O;VP 
M;6%N9&%T;W)Y)R!P87)A;65T97)S+ T*"2`J(&1E9F%U;'1686QU92!I<R!T
M;R!S970 82!D969A=6QT('9A;'5E(&9O<B!O<'1I;VYS('=I=&  =F%L=65S
M(&%N9"!M86ME('1H870-" D *B!O<'1I;VX 86QW87ES(&9O=6YD('=I=&  
M=&AA="!V86QU92!B>2!D969A=6QT+B` ;6%N9&%T;W)Y('-P96-I9FEE<R!W

M;VUM86YD+6QI;F4N("!)9B!B;W1H(&1E9F%U;'1686QU92!A;F0-" D *B!A
M;F0 ;6%N9&%T;W)Y(&%R92!G:79E;BP ;6%N9&%T;W)Y('=I;&P :&%V92!N
M;R!E9F9E8W0N("!)9B!D969A=6QT5F%L=64 :7,-" D *B!N=6QL+"!I="!M
M96%N<R!N;R!D969A=6QT('9A;'5E+B` 9&5F875L=%9A;'5E(&UU<W0 8F4 
M;G5L;"!F;W( ;F\M=F%L=64-" D *B!O<'1I;VYS('1H870 ;F5E9"!T;R!S

M("A4(#T
M:&]R=$YA;64L(&-H87);72!L;VYG3F%M92`](&YU;&PL(&-H87);72!H96QP
M(#T
M96)U9R!W<FET969L;B B)7,N861D3W!T:6]N*"DB+"!T:&ES*3L-" T*"0EI

M"0ET:')O=R!N97< 3W!T4&%R<V5%<G)O<B B861D3W!T:6]N*"D <F5Q=6ER


M<B B861D3W!T:6]N*"D =&%K97, 870 ;6]S="!T=V\ =F%R:6%D:6, 87)G

M:6]N<RD >PT*"0D):68 *'-H;W)T3F%M92YL96YG=&  )B8 <VAO<G1.86UE
M(#T](&\N<VAO<G1.86UE*0T*"0D)"71H<F]W(&YE=R!/<'1087)S945R<F]R
M*")C;V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A
M<G-I;F< =F%L=64M<W1R:6YG(%PB)7-<(B!A<R`E<SH )7,B+"!O+"!V+"!O

M9$]P=&EO;G,I('L-" D)"7!R:6YT2&5L<" I.PT*"0D)97AI=" P*3L-" D)
M?0T*"0EI9B`H(G9E<G-I;VXB(&EN(&9O=6YD3W!T:6]N<RD >PT*"0D)<')I

M;6%N9&%T;W)Y(&]P=&EO;G, 87)E(&EN(&9O=6YD3W!T:6]N<PT*"0EF;W)E

M86YD871O<GDI('L-" D)"0EB;V]L(&9O=6YD.PT*"0D)"69O<F5A8V  *$)A
M<V5/<'1I;VX 9F\[(&9O=6YD3W!T:6]N<RD-" D)"0D):68 *&9O(&ES(&\I

M=&AR;W< ;F5W($]P=&EO;D5R<F]R*&9O<FUA=" B)7, ;W!T:6]N(&ES(&UA


M969L;B B)7,N<&%R<V4H*2!D;VYE+B(L('1H:7,I.PT*"0EA<F=S(#T ;&5F
M=&]V97)!<F=S.PT*"0ER971U<FX 9F]U;F1/<'1I;VYS.PT*"7T-" T*"79O




M;VAL(#X ,C$I('L-" D)"0EC:&%R6UT <F5T(#T (EQN(CL-" D)"0EC:&%R
M6UT :6YD96YT(#T



M92YL96YG=&  /B`W,BD >PT*"0D)"0D);&EN97, ?CT ;&EN93L-" D)"0D)

M;F=T:"D-" D)"0D);&EN97, ?CT ;&EN93L-" D)"0EF;W)E86-H("AC:&%R
M6UT ;#L

M"0ER971U<FX ;6%K94EN9&5N=" R-"`M(&]H;"D ?B!H.PT*"0D)?0T*"0E]


M<R`E<UQN(BP <')O9TYA;64L('5S86=E*3L-" D)?0T*"0EF;W)E86-H("A/
M<'1I;VY'<F]U<"!G<F]U<#L


M;VX ;SL 9W)O=7`N;W!T:6]N<RD >PT*"0D)"6-H87);72!O<'1(96QP(#T 


M87(N;&5N9W1H*0T*"0D)"0D);W!T2&5L<"!^/2`B("( ?F\N;65T859A<CL-
M" D)"0D):68 *&\N;&]N9TYA;64N;&5N9W1H*0T*"0D)"0D);W!T2&5L<"!^
M/2`B+"`B.PT*"0D)"7T-" D)"0EI9B`H;RYL;VYG3F%M92YL96YG=& I('L-
M" D)"0D);W!T2&5L<"!^/2`B+2TB('X ;RYL;VYG3F%M93L-" D)"0D):68 


M"6]P=$AE;'` ?CT 86QI9VY/<'1(96QP4W1R*&\N:&5L<"P ;W!T2&5L<"YL

M"7T-" D)=W)I=&5F*&AE;'`I.PT*"7T-" T*"79O:60 <')I;G1697)S:6]N


M:71E9FQN*"(E<SH 97)R;W(Z("5S7&XB+"!P<F]G3F%M92P ;7-G*3L-" D)



M9R!W<FET969L;B B)7,N<&%R<V5!<G)A>2$H)7,I*'9S/5PB)7-<(B!P87)S
M950])7,I(BP =&AI<RP ='EP96ED*%0I+"!V<RP <&%R<V54*3L-" D)5%M=

M:"`H8VAA<EM=(',[('-S*0T*"0D):68 *',N;&5N9W1H*0T*"0D)"6$ ?CT 


M;F1E9"!T;R!B92!U<V5D('-O;65T:&EN9R!L:6ME. T*("H :68 *")O<'1I








M('1O(&%L;"!O<'1I;VYS(&%N9"!P<F]V:61E<R!T96UP;&%T92!F;W(-"B`J
M(')E=')I979I;F< ;W!T:6]N('9A;'5E<R!A<R!T:&4 8V]R<F5C="!T>7!E

M" EC:&%R6UT <VAO<G1.86UE+"!L;VYG3F%M93L-" EC:&%R6UT :&5L<"P 
M;65T859A<CL-" EB;V]L(&UA;F1A=&]R>3L-" E3=7!P;W)T9614>7!E<R!T

M;W)T9614>7!E<R!T+"!4>7!E26YF;R!T:2P 8VAA<EM=('-.86UE+"!C:&%R

M<V5R="`H=&D (3T](&YU;&PI.PT*"0EA<W-E<G0 *'-.86UE+FQE;F=T:"!\

M"5]T>7!E(#T
M92`](&Q.86UE.PT*"0EH96QP(#T :#L-
M"61E8G5G('=R:71E9FQN*"(E<RYT:&ES*"D 9&]N92`M+2!T>7!E(#T )60 
M(%]T>7!E(#T


M("` ("` ("` ("` ("` 268 =&AE('=R;VYG('1Y<&4 :7, 871T96UP=&5D
M+"!/<'1087)S945R<F]R(&ES('1H<F]W;BX-" D *B\-" ET96UP;&%T92!G

M<&4 /3T 4W5P<&]R=&5D5'EP97,N3F]686QU92D-" D)"71H<F]W(&YE=R!/
M<'1087)S945R<F]R*&9O<FUA=" B)7, ;W!T:6]N(&1O97, ;F]T(&AA=F4 
M82!V86QU92!T;R!R971R:65V92(L('1H:7,I*3L-" T*"0ET<GD >PT*"0D)
M:68 *&=E=%-4(2A4*2`A/2!T>7!E*0T*"0D)"71H<F]W(&YE=R!/<'1087)S
M945R<F]R*&9O<FUA=" B)7, ;W!T:6]N(&UU<W0 8F4 <F5T<FEE=F5D(&%S
M('1Y<&4 )7,L(&YO="!T>7!E("5S(BP =&AI<RP 7W1Y<&4L('1Y<&5I9"A4

M*0T*"0D)=&AR;W< ;F5W($]P=%!A<G-E17)R;W(H9F]R;6%T*"(E<R!O<'1I
M;VX 8V%N(&YO="!B92!R971R:65V960 87, =6YS=7!P;W)T960 ='EP92`E









M(%!A<F%M971E<FEZ960 8GD 82!T>7!E('1O('-P96-I9FEY(&$ =F%L=64-
M"B`J(&ES(&5X<&5C=&5D(&%N9"!W:&%T('1Y<&4L(&]R($YO5F%L=64 =&\ 

M"B`J+PT*<')I=F%T92!C;&%S<R!/<'1I;VX *%0I(#H 0F%S94]P=&EO; T*

M('T-" T*"71H:7, *&-H87);72!S:&]R=$YA;64L(&-H87);72!L;VYG3F%M
M92P 8VAA<EM=(&AE;'`L(&-H87);72!M971A5F%R*0T*"7L-" D)=')Y('L-
M" D)"7-U<&5R*&=E=%-4(2A4*2P ='EP96ED*%0I+"!S:&]R=$YA;64L(&QO
M;F=.86UE+"!H96QP+"!M971A5F%R*3L-" D)?0T*"0EC871C:"`H56Y3=7!P
M;W)T9614>7!E17)R;W( =7-T92D >PT*"0D)=&AR;W< ;F5W($]P=%!A<G-E
M17)R;W(H9F]R;6%T*"(E<R!O<'1I;VX 8V%N(&YO="!B92!U;G-U<'!O<G1E
M9"!T>7!E("5S(BP ;W!T5&]3=')I;F<H<VAO<G1.86UE+&QO;F=.86UE*2P 

M96)U9R!W<FET969L;B B8F5G:6X )7, =6YI='1E<W0B+"!?7T9)3$5?7RD[



M>PT*"0EO<'1I;VY087)S97( /2!N97< 3W!T:6]N4&%R<V5R*%]?1DE,15]?
M6S`N+B0M,ETL(");;W!T:6]N(%MV86QU95U=(BP (C`N,"(I.PT*"0EO<'1I
M;VY087)S97(N861D3W!T:6]N(2 I*")V(BP (G9E<F)O<V4B*3L-" D);W!T
M:6]N4&%R<V5R+F%D9$]P=&EO;B$H9FQO870I*")F(BP (F9O;R(L(&YU;&PL
M(&YU;&PL(&YU;&PL('1R=64I.PT*"0EO<'1I;VY087)S97(N861D3W!T:6]N
M(2AI;G0I*")X(BP (GAE;F\B+"`B9&]E<R!T:&ES(&%N9"!T:&%T(BP (E1(
M24Y'(BP ,3(S*3L-" D);W!T:6]N4&%R<V5R+F%D9$]P=&EO;B$H:6YT6UTI
M*")A(BP (F%P<&QE(BP (FUA:V4 87!P;&5S875C92(L(&YU;&PI.PT*"0EO
M<'1I;VY087)S97(N861D3W!T:6]N(2AL;VYG*2 B;"(L(")L;VYG(BP (F)E

M*&1O=6)L92DH(F0B+"`B9&]U8FQE(BP ;G5L;"P (D1/54),12(I.PT*"0EO
M<'1I;VY087)S97(N861D3W!T:6]N(2AU:6YT6UTI*")U:2(L(")U:6YT(BP 

M(FYU;6)E<B!O<'1I;VYS(BP (F8B+"`B>"(L(")A(BP (FPB+"`B9"(L(")U
M:2(I.PT*"0EO<'1I;VY087)S97(N861D3W!T:6]N(2AC:&%R6UTI*&YU;&PL
M(")B87(B+"`B;6%K92!I="!H87!P96XB+"`B0DQ/0B(L(")D969A=6QT+79A

M<V(B+"`B<VAA8F%N9R(L(")B;&]W('5P(BP (DE4(BP <VAA8F%N9T1F;'0I
M.PT*"0EO<'1I;VY087)S97(N;6%K94=R;W5P*")S=')I;F< ;W!T:6]N<R(L


M*")M>6%P<"!L86QA("UV("TM9F]O/3DX-RXV-2`M+6)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3(S*3L-" DO+R!.;U9A;'5E(&1E9F%U;'1686QU
M92!M=7-T(#T](&YU;&P =VAE;B!M86YD871O<GD-" DO+V]P=&EO;E!A<G-E


M87!P("UV(&%S9&8 +2UX96YO/34T,S(Q('AY>B`M9C`N.3DB*3L-" DO+V]P



M92`](&]P=&EO;G-;(G9E<F)O<V4B72YG971686QU92$H:6YT*3L-" DO+V%S
M<V5R="`H9F%I;',H9&5L96=A=&4 =F]I9"`H*2![(&]P=&EO;G-;(G9E<F)O
M<V4B72YG971686QU92$H8F]O;"D[('TI*3L ("\O(&-A=7-E<R!$340 8G5G
M($D 8V%N)W0 <F5P<F]D=6-E('-I;7!L97(L(&EF(&)O;VP 8B`]('-T871M



M97(N;6%K94=R;W5P*")C<F%P(&]P=&EO;G,B+"`B;6ES<VEN9R(I.PT*"2\O

M<'1I;VY087)S97(N861D3W!T:6]N(2 I*&YU;&PL(&YU;&PL(")W:&%T(&%M
M($D 9&]I;F<_(2(I.PT*"2\O(&UI<W-I;F< 9W)O=7` =&ET;&4-" DO+V]P
M=&EO;E!A<G-E<BYM86ME1W)O=7`H;G5L;"P (G9E<F)O<V4B*3L-" DO+R!W



M<VEO;B`H3W!T4&%R<V5-86EN*0T*>PT*"2\J* T*"2`J(%=O<FMI;F< 97AA
M;7!L92!U<V%G92X-" D *B\-" EI;G0 ;6%I;B`H8VAA<EM=6UT 87)G<RD-

M:&%R6UU;72!F:6QE<SL-" T*"0DO+R!C;VYS=')U8W1O<B!A<F=S(&%R92!U
M<V5D(&EN('!R:6YT:6YG(&AE;'`-" D)+R\ ;W!T:6]N("UH("\ +2UH96QP
M(&ES(&%L=V%Y<R!A9&1E9"!B>2!D969A=6QT(&%N9"!U<V5S('!R;V=R86TM
M;F%M92!A;F0 =7-A9V4-" D)+R\ ;W!T:6]N("TM=F5R<VEO;B`H;F\ <VAO
M<G0 ;F%M92D :7, 861D960 8GD 9&5F875L="!I9B!V97)S:6]N(&ES(&=I

M<F]G<F%M+6YA;64 ("`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`P*0T*"0D);W`N97)R;W)%>&ET*")N965D('1O('-P96-I9FEY(&%T(&QE


M;&XH(FUY('1H:6YG(&ES.B`B+"!O<'1I;VYS6R)T:&EN9R)=+F=E=%9A;'5E



M<R!U<VEN9R!A;'1E<FYA=&4 ;65T:&]D.B(I.PT*"0D)96QS90T*"0D)"7=R
M:71E9FQN*"))('=O=6QD('!R;V-E<W, 9FEL97, =7-I;F< ;F]R;6%L(&UE
M=&AO9#HB*3L-" D)"69O<F5A8V  *&-H87);72!F.R!F:6QE<RD-" D)"0EW
M<FET969L;B B7'0B+&8I.PT*"0D)=W)I=&5F;&XH(F%N9"!O=71P=70 =&\ 
M(BP ;W5T9FEL92YL96YG=&  /R!O=71F:6QE(#H
:"7T-" T*"0ER971U<FX ,#L-
`
end
Jun 01 2005
prev sibling parent reply "Andrew Fedoniouk" <news terrainformatica.com> writes:
Cool, Derick!

What about using box values there?

Having them and use TypeList instead of

  optionParser = new OptionParser(__FILE__[0..$-2], "[option [value]]", 
"0.0");
  optionParser.addOption!()("v","verbose");
  optionParser.addOption!(float)("f","foo",null,null,null,true);
  optionParser.addOption!(int)("x","xeno","does this and that","THING",123);

will allow to build such declarations in compile time - statically.

Just hypothesis....

Andrew.



<derick_eddington nospam.yashmoo.com> wrote in message 
news:d7g5nd$3i3$1 digitaldaemon.com...
 I've made a command-line option helper similar to Python's optparse.  It 
 allows
 you to specify what D-type you want the option as, short name, long name, 
 help,
 and more.  It automatically creates a formatted help message and prints it 
 on
 errors.  It checks that clients' usage of the module is proper; and it 
 checks
 that the command-line arguments meet what was specified.  It has a 
 compehensive
 unittest that demonstrates more.  The source is attached.

 : /**
 :  * Example usage:
 :  */
 : int main (char[][] args)
 : {
 :     int verbosity;
 :     char[] outfile;
 :     char[][] files;
 :
 :     // Constructor parameters are used in printing help.
 :     // -h / --help is always added by default
 :     // and uses program-name and usage.
 :     // --version (no short name) is added by
 :     // default if version is given.
 :     //                                   program-name
 :     OptionParser op = new OptionParser(__FILE__[0..$-2],
 :     //                 usage                version
 :         "[options] --files=f1,fN [outfile]", "0.2");
 :
 :     // int, short and long, help, metavar,
 :     // no default, not mandatory
 :     op.addOption!(int)("v", "verbose",
 :         "Be more and more and more and more and more "
 :         "and more and more verbose.", "LEVEL");
 :     // comma-separated string list, short and long, help,
 :     // metavar, no default, mandatory
 :     op.addOption!(char[][])("fs", "files",
 :         "Files to process, and make this a really long help "
 :         "string as well to test aligning.", "FILE,FILE,...",
 :         null, true);
 :     // float, long-only, help, metavar, default, not mandatory
 :     op.addOption!(float)(null, "thing", "Do it with this.",
 :         "FLOAT", -4.297e21f);
 :     // no-value, short-only, with help, no metavar,
 :     // no default, not mandatory
 :     op.addOption!()("a", null, "Use alternate method.");
 :
 :     // Parse command-line arguments, including args[0]
 :     // program-name (it's skipped).
 :     // args will be reset to the remaining non-option
 :     // command-line arguments in the order they appeared.
 :     Options options = op.parse(args);
 :
 :     // Check if option was given on the command-line
 :     // by using (char[] in Options).
 :     // If the option has both short and long names,
 :     // either can be used.
 :     if ("verbose" in options)
 :         // If option was given and it has a value,
 :         // retrieve it by indexing Options with short
 :         // or long name (or only one if only one)
 :         // and do getValue!(T)
 :         verbosity = options["verbose"].getValue!(int);
 :
 :     if (verbosity > 0)
 :         writefln("I'll say a little.");
 :     if (verbosity > 1)
 :         writefln("I'll say a lot more.");
 :
 :     // args was reset by parse to the remaining
 :     // non-option command-line arguments
 :     if (args.length == 1)
 :         // use the first non-option argument
 :         outfile = args[0];
 :     else if (args.length > 1)
 :         // OptionError.errorExit("message") can be used to
 :         // print help and exit process;
 :         // useful when checking non-option arguments
 :         op.errorExit("more than one output file specified");
 :
 :     // mandatory options can be assumed to be
 :     // there after successful parse
 :     assert ("files" in options);
 :     files = options["files"].getValue!(char[][]);
 :     if (files.length == 0)
 :         op.errorExit("need to specifiy at least one input file");
 :
 :     if (verbosity > 0)
 :     {
 :         if ("thing" in options)
 :             writefln("my thing is: ",
 :                 options["thing"].getValue!(float));
 :
 :         // no-value options are simply tested for being in Options
 :         if ("a" in options)
 :             writefln("I would process files using alternate method:");
 :         else
 :             writefln("I would process files using normal method:");
 :         foreach (char[] f; files)
 :             writefln("\t",f);
 :         writefln("and output to ",
 :             outfile.length ? outfile : "<stdout>");
 :     }
 :
 :     return 0;
 : }

 Example command-line output of above program:

 ---------------------------------------------------------------

 $ ./example -h
 usage:  optparse [options] --files=f1,fN [outfile]

 options:
 -h, --help            Show this help message and exit.
 --version             Show program's version number and exit.
 -vLEVEL, --verbose=LEVEL
 Be more and more and more and more and more and more
 and more verbose.
 -fsFILE,FILE,..., --files=FILE,FILE,...
 Files to process, and make this a really long help
 string as well to test aligning.
 --thing=FLOAT         Do it with this.
 -a                    Use alternate method.

 ---------------------------------------------------------------

 $ ./example -v2 --files=somefile,anotherfile,nextfile --thing -4.23e-6 -a
 outputfile
 I'll say a little.
 I'll say a lot more.
 my thing is: -4.23e-06
 I would process files using alternate method:
 somefile
 anotherfile
 nextfile
 and output to outputfile

 ---------------------------------------------------------------

 $ ./example --asdf
 optparse: error: no such option: --asdf

 [help]

 ---------------------------------------------------------------

 $ ./example
 optparse: error: -fs / --files option is mandatory

 [help]



 
May 31 2005
parent reply derick_eddington nospam.yashmoo.com writes:
If it could be setup statically at compile-time and have the same conciseness,
flexibility, and ease of checking for options and retrieving their values, that
would be awesome, but I don't follow what you mean about box values and
TypeList.  Could you elaborate?

The only way to parameterize something at compile-time is with templates, right?
But they can only take integral values, not char[] for option names or arbitrary
types for default values.  Statically-initialized structs could be used but then
they still have to be given to an OptionParser and variables for them would also
need to be declared.  I don't think it can be done and retain the same degree of
simpleness of use.


In article <d7iifp$2jhh$1 digitaldaemon.com>, Andrew Fedoniouk says...
Cool, Derick!

What about using box values there?

Having them and use TypeList instead of

  optionParser = new OptionParser(__FILE__[0..$-2], "[option [value]]", 
"0.0");
  optionParser.addOption!()("v","verbose");
  optionParser.addOption!(float)("f","foo",null,null,null,true);
  optionParser.addOption!(int)("x","xeno","does this and that","THING",123);

will allow to build such declarations in compile time - statically.

Just hypothesis....

Andrew.
Jun 01 2005
parent "Andrew Fedoniouk" <news terrainformatica.com> writes:
<derick_eddington nospam.yashmoo.com> wrote in message 
news:d7jvl1$1420$1 digitaldaemon.com...
 If it could be setup statically at compile-time and have the same 
 conciseness,
 flexibility, and ease of checking for options and retrieving their values, 
 that
 would be awesome, but I don't follow what you mean about box values and
 TypeList.  Could you elaborate?

 The only way to parameterize something at compile-time is with templates, 
 right?
 But they can only take integral values, not char[] for option names or 
 arbitrary
 types for default values.  Statically-initialized structs could be used 
 but then
 they still have to be given to an OptionParser and variables for them 
 would also
 need to be declared.  I don't think it can be done and retain the same 
 degree of
 simpleness of use.
Yep. You are right. I was thinking about simple implementation of something close to boost::spirit http://spirit.sourceforge.net/ but it seems like even simple implementation is an overkill for such task. Andrew.
 In article <d7iifp$2jhh$1 digitaldaemon.com>, Andrew Fedoniouk says...
Cool, Derick!

What about using box values there?

Having them and use TypeList instead of

  optionParser = new OptionParser(__FILE__[0..$-2], "[option [value]]",
"0.0");
  optionParser.addOption!()("v","verbose");
  optionParser.addOption!(float)("f","foo",null,null,null,true);
  optionParser.addOption!(int)("x","xeno","does this and 
 that","THING",123);

will allow to build such declarations in compile time - statically.

Just hypothesis....
Andrew.
Jun 01 2005