From 0d3d73fb0cacd3d1cf7eb8b83ba87f8b740b871a Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Wed, 16 Dec 2009 23:54:13 +0000 Subject: Signals is even safer and works even better. Also, OptParser is nearly done. Now I just have to come up with a way to modify data that you already have, that sure was a nice feature of the old one, even if it was implemented in a silly way. --- src/tests/optparser.cpp | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'src/tests/optparser.cpp') diff --git a/src/tests/optparser.cpp b/src/tests/optparser.cpp index 9168af8..ee2ea58 100644 --- a/src/tests/optparser.cpp +++ b/src/tests/optparser.cpp @@ -8,13 +8,30 @@ public: Opts() : iBob( 542 ) { - callback( this, &Opts::cb ); + Option o; + o.sUsed = slot( this, &Opts::cb ); + o.cOpt = 'x'; + o.sOpt = "things"; + o.bShortHasParams = true; + o.sHelp = "This is the first test parameter. It calls a function, and takes parameters."; + addOption( o ); + + Option o2; + o2.sUsed = slot( this, &Opts::cb ); + o2.cOpt = 'y'; + o2.sOpt = "stuff"; + o2.bShortHasParams = false; + o2.sHelp = "This is the second test parameter. It does not take parameters. However, I do want to make this part much longer to see how it looks when you add way too much text to one of these things. It can't really be that bad, right?"; + addOption( o2 ); + + addHelpOption('h', "help", "This help."); } - int cb( int argc, char *argv[] ) + int cb( StrArray aParams ) { sio << "Hey, cb was called, here's a class var: " << iBob << sio.nl; - return 5; + sio << "argv[] = " << aParams << sio.nl; + return 1; } int iBob; @@ -23,5 +40,7 @@ public: int main( int argc, char *argv[] ) { Opts o; + + o.parse( argc, argv ); } -- cgit v1.2.3