diff --git a/docs/manual.html b/docs/manual.html index 5a12863..9b0f04c 100644 --- a/docs/manual.html +++ b/docs/manual.html @@ -1,7 +1,7 @@ -Templatized C++ Command Line Parser Manual

Templatized C++ Command Line Parser Manual

Michael E Smoot


Table of Contents

1. Basic Usage
Overview
Example
Library Properties
Common Argument Properties
Compiling
2. Fundamental Classes
CmdLine
SwitchArg
ValueArg
MultiArg
MultiSwitchArg
UnlabeledValueArg
UnlabeledMultiArg
3. Complications
I want to combine multiple switches into one argument...
I want one argument or the other, but not both...
I have more arguments than single flags make sense for...
I want to constrain the values allowed for a particular -argument...
I want the Args to add themselves to the CmdLine...
I want different output than what is provided...
I don't want the --help and --version switches to be created automatically...
I want to ignore certain arguments...
I want to read hex integers as arguments...
I want to use different types...
I want to use Windows-style flags like "/x" and "/y"...
4. Notes
Type Descriptions
Visitors
More Information

Chapter 1. Basic Usage

Overview

+Templatized C++ Command Line Parser Manual

Templatized C++ Command Line Parser Manual

Michael E Smoot


Chapter 1. Basic Usage

Overview

TCLAP has a few key classes to be aware of. The first is the CmdLine (command line) class. This class parses @@ -414,7 +414,7 @@ then just declare the UnlabeledMultiArg as type string and parse the different values yourself or use several UnlabeledValueArgs.

Naturally, what we have seen to this point doesn't satisfy all of our needs.

I want to combine multiple switches into one argument...

@@ -703,6 +703,47 @@ ignore arguments after the --. To accomm we can make both UnlabeledValueArgs and UnlabeledMultiArgs ignoreable in their constructors. See the API Documentation for details. +

I want to ignore unmatched arguments...

+By default, if TCLAP sees an argument that doesn't +match a specified Arg, it will produce an exception. +This strict handling provides some assurance that all input to a program +is controlled. However, there are times when +this strict handling of arguments might not be desirable. The alternative +that TCLAP provides is to simply ignore any unmatched +arguments on the command line. This is accomplished by calling the +ignoreUnmatched method with +true on the +CmdLine object that's been constructed. + +

+
+    // Define the command line object.
+	CmdLine cmd("Command description message", ' ', "0.9");
+
+	// Tell the command line to ignore any unmatched args.
+	cmd.ignoreUnmatched(true);
+
+    // Define a value argument and add it to the command line.
+	ValueArg<string> nameArg("n","name","Name to print",true,"homer","string");
+	cmd.add( nameArg );
+
+    // Parse the args.
+    cmd.parse( argc, argv );
+
+

+ +Given the program above, if a user were to type: + +

+
+	% command -n Mike something to ignore
+
+

+ +The program would succeed and the name ValueArg +would be populated with "Mike" but +the strings "something", "to", and "ignore" would simply be ignored by the +parser.

I want to read hex integers as arguments...

Sometimes it's desirable to read integers formatted in decimal, hexadecimal, and octal format. This is now possible by #defining the TCLAP_SETBASE_ZERO diff --git a/docs/manual.xml b/docs/manual.xml index 2f20d71..6a068a8 100644 --- a/docs/manual.xml +++ b/docs/manual.xml @@ -30,7 +30,7 @@ E - 2003,2004,2005,2006,2009,2011 + 2003,2004,2005,2006,2009,2011,2012 Michael E. Smoot @@ -903,6 +903,52 @@ See the API Documentation for details. + +I want to ignore unmatched arguments... + +By default, if TCLAP sees an argument that doesn't +match a specified Arg, it will produce an exception. +This strict handling provides some assurance that all input to a program +is controlled. However, there are times when +this strict handling of arguments might not be desirable. The alternative +that TCLAP provides is to simply ignore any unmatched +arguments on the command line. This is accomplished by calling the +ignoreUnmatched method with +true on the +CmdLine object that's been constructed. + + + + // Define the command line object. + CmdLine cmd("Command description message", ' ', "0.9"); + + // Tell the command line to ignore any unmatched args. + cmd.ignoreUnmatched(true); + + // Define a value argument and add it to the command line. + ValueArg<string> nameArg("n","name","Name to print",true,"homer","string"); + cmd.add( nameArg ); + + // Parse the args. + cmd.parse( argc, argv ); + + + +Given the program above, if a user were to type: + + + + % command -n Mike something to ignore + + + +The program would succeed and the name ValueArg +would be populated with "Mike" but +the strings "something", "to", and "ignore" would simply be ignored by the +parser. + + + I want to read hex integers as arguments...