MultiSwitchArg

This commit is contained in:
mes5k 2005-01-24 00:27:29 +00:00
parent 2f941785c3
commit 4921db78a1
3 changed files with 46 additions and 1 deletions

View File

@ -1,5 +1,5 @@
noinst_PROGRAMS = test1 test2 test3 test4 test5 test6 test7 test8
noinst_PROGRAMS = test1 test2 test3 test4 test5 test6 test7 test8 test9
test1_SOURCES = test1.cpp
test2_SOURCES = test2.cpp
@ -9,6 +9,7 @@ test5_SOURCES = test5.cpp
test6_SOURCES = test6.cpp
test7_SOURCES = test7.cpp
test8_SOURCES = test8.cpp
test9_SOURCES = test9.cpp
INCLUDES = -I$(top_builddir)/include

43
examples/test9.cpp Normal file
View File

@ -0,0 +1,43 @@
#include <string>
#include <iostream>
#include <algorithm>
#include <tclap/CmdLine.h>
using namespace TCLAP;
using namespace std;
int main(int argc, char** argv)
{
try {
CmdLine cmd("Command description message", ' ', "0.9",false);
SwitchArg reverseSwitch("r","reverse","REVERSE instead of FORWARDS", false);
cmd.add( reverseSwitch );
MultiSwitchArg verbose("V","verbose","Level of verbosity");
cmd.add( verbose );
MultiSwitchArg noise("N","noise","Level of noise",5);
cmd.add( noise );
cmd.parse( argc, argv );
bool reverseName = reverseSwitch.getValue();
if ( reverseName )
cout << "REVERSE" << endl;
else
cout << "FORWARD" << endl;
if ( verbose.isSet() )
cout << "Verbose level: " << verbose.getValue() << endl;
if ( noise.isSet() )
cout << "Noise level: " << noise.getValue() << endl;
} catch (ArgException &e) // catch any exceptions
{ cerr << "error: " << e.error() << " for arg " << e.argId() << endl; }
}

View File

@ -13,6 +13,7 @@ libtclapinclude_HEADERS = \
Visitor.h Arg.h \
HelpVisitor.h \
SwitchArg.h \
MultiSwitchArg.h \
VersionVisitor.h \
IgnoreRestVisitor.h \
CmdLineOutput.h \