From 634cbb01f5d39a4f319428a9f6e0a2c0adf3491c Mon Sep 17 00:00:00 2001 From: Mike Smoot Date: Sun, 25 Nov 2012 14:04:36 -0800 Subject: [PATCH] Updated manual for ignore unmatched args. --- docs/manual.html | 47 ++++++++++++++++++++++++++++++++++++++++++++--- docs/manual.xml | 48 +++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 91 insertions(+), 4 deletions(-) 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


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...