aboutsummaryrefslogtreecommitdiff
path: root/src/tests/optparser.cpp
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2009-12-16 23:54:13 +0000
committerMike Buland <eichlan@xagasoft.com>2009-12-16 23:54:13 +0000
commit0d3d73fb0cacd3d1cf7eb8b83ba87f8b740b871a (patch)
tree5e5933681454276d73ceb4ce18719244c9c76d18 /src/tests/optparser.cpp
parentafac5804b069e5eb76c799e9edd2eaeff0d99b94 (diff)
downloadlibbu++-0d3d73fb0cacd3d1cf7eb8b83ba87f8b740b871a.tar.gz
libbu++-0d3d73fb0cacd3d1cf7eb8b83ba87f8b740b871a.tar.bz2
libbu++-0d3d73fb0cacd3d1cf7eb8b83ba87f8b740b871a.tar.xz
libbu++-0d3d73fb0cacd3d1cf7eb8b83ba87f8b740b871a.zip
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.
Diffstat (limited to 'src/tests/optparser.cpp')
-rw-r--r--src/tests/optparser.cpp25
1 files changed, 22 insertions, 3 deletions
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:
8 Opts() : 8 Opts() :
9 iBob( 542 ) 9 iBob( 542 )
10 { 10 {
11 callback( this, &Opts::cb ); 11 Option o;
12 o.sUsed = slot( this, &Opts::cb );
13 o.cOpt = 'x';
14 o.sOpt = "things";
15 o.bShortHasParams = true;
16 o.sHelp = "This is the first test parameter. It calls a function, and takes parameters.";
17 addOption( o );
18
19 Option o2;
20 o2.sUsed = slot( this, &Opts::cb );
21 o2.cOpt = 'y';
22 o2.sOpt = "stuff";
23 o2.bShortHasParams = false;
24 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?";
25 addOption( o2 );
26
27 addHelpOption('h', "help", "This help.");
12 } 28 }
13 29
14 int cb( int argc, char *argv[] ) 30 int cb( StrArray aParams )
15 { 31 {
16 sio << "Hey, cb was called, here's a class var: " << iBob << sio.nl; 32 sio << "Hey, cb was called, here's a class var: " << iBob << sio.nl;
17 return 5; 33 sio << "argv[] = " << aParams << sio.nl;
34 return 1;
18 } 35 }
19 36
20 int iBob; 37 int iBob;
@@ -23,5 +40,7 @@ public:
23int main( int argc, char *argv[] ) 40int main( int argc, char *argv[] )
24{ 41{
25 Opts o; 42 Opts o;
43
44 o.parse( argc, argv );
26} 45}
27 46