├── .gitignore ├── AUTHORS ├── CMakeLists.txt ├── COPYING ├── ChangeLog ├── INSTALL ├── Makefile.am ├── NEWS ├── README ├── autotools.sh ├── config ├── Makefile.am ├── ac_cxx_have_long_long.m4 ├── ac_cxx_have_sstream.m4 ├── ac_cxx_have_strstream.m4 ├── ac_cxx_namespaces.m4 ├── ac_cxx_warn_effective_cxx.m4 ├── bb_enable_doxygen.m4 ├── depcomp ├── install-sh ├── missing └── mkinstalldirs ├── configure.ac ├── docs ├── Doxyfile.in ├── Makefile.am ├── README ├── build.html ├── index.html ├── manual.html ├── manual.xml ├── style.css └── upload.sh ├── examples ├── CMakeLists.txt ├── Makefile.am ├── test-hard-1.cpp ├── test-hard-2.cpp ├── test1.cpp ├── test10.cpp ├── test11.cpp ├── test12.cpp ├── test13.cpp ├── test14.cpp ├── test15.cpp ├── test16.cpp ├── test18.cpp ├── test19.cpp ├── test2.cpp ├── test20.cpp ├── test21.cpp ├── test22.cpp ├── test23.cpp ├── test24.cpp ├── test25.cpp ├── test26.cpp ├── test27.cpp ├── test28.cpp ├── test29.cpp ├── test3.cpp ├── test30.cpp ├── test4.cpp ├── test5.cpp ├── test6.cpp ├── test7.cpp ├── test8.cpp └── test9.cpp ├── include ├── Makefile.am └── tclap │ ├── Arg.h │ ├── ArgException.h │ ├── ArgTraits.h │ ├── CmdLine.h │ ├── CmdLineInterface.h │ ├── CmdLineOutput.h │ ├── Constraint.h │ ├── DocBookOutput.h │ ├── HelpVisitor.h │ ├── IgnoreRestVisitor.h │ ├── Makefile.am │ ├── MultiArg.h │ ├── MultiSwitchArg.h │ ├── OptionalUnlabeledTracker.h │ ├── StandardTraits.h │ ├── StdOutput.h │ ├── SwitchArg.h │ ├── UnlabeledMultiArg.h │ ├── UnlabeledValueArg.h │ ├── ValueArg.h │ ├── ValuesConstraint.h │ ├── VersionVisitor.h │ ├── Visitor.h │ ├── XorHandler.h │ ├── ZshCompletionOutput.h │ └── sstream.h ├── msc ├── Makefile.am ├── README ├── examples │ ├── Makefile.am │ ├── test1.vcproj │ ├── test2.vcproj │ ├── test3.vcproj │ ├── test4.vcproj │ ├── test5.vcproj │ ├── test6.vcproj │ ├── test7.vcproj │ └── test8.vcproj ├── tclap-beta.ncb ├── tclap-beta.sln ├── tclap-beta.suo └── tclap-beta.vcproj ├── scripts ├── check_dead_headers.py ├── check_tests_enabled.py ├── fix-test.py └── modeline.py ├── tclap.pc.in └── tests ├── Makefile.am ├── genOut.pl ├── runtests.sh ├── simple-test.sh ├── test1.out ├── test1.sh ├── test10.out ├── test10.sh ├── test11.out ├── test11.sh ├── test12.out ├── test12.sh ├── test13.out ├── test13.sh ├── test14.out ├── test14.sh ├── test15.out ├── test15.sh ├── test16.out ├── test16.sh ├── test17.out ├── test17.sh ├── test18.out ├── test18.sh ├── test19.out ├── test19.sh ├── test2.out ├── test2.sh ├── test20.out ├── test20.sh ├── test21.out ├── test21.sh ├── test22.out ├── test22.sh ├── test23.out ├── test23.sh ├── test24.out ├── test24.sh ├── test25.out ├── test25.sh ├── test26.out ├── test26.sh ├── test27.out ├── test27.sh ├── test28.out ├── test28.sh ├── test29.out ├── test29.sh ├── test3.out ├── test3.sh ├── test30.out ├── test30.sh ├── test31.out ├── test31.sh ├── test32.out ├── test32.sh ├── test33.out ├── test33.sh ├── test34.out ├── test34.sh ├── test35.out ├── test35.sh ├── test36.out ├── test36.sh ├── test37.out ├── test37.sh ├── test38.out ├── test38.sh ├── test39.out ├── test39.sh ├── test4.out ├── test4.sh ├── test40.out ├── test40.sh ├── test41.out ├── test41.sh ├── test42.out ├── test42.sh ├── test43.out ├── test43.sh ├── test44.out ├── test44.sh ├── test45.out ├── test45.sh ├── test46.out ├── test46.sh ├── test47.out ├── test47.sh ├── test48.out ├── test48.sh ├── test49.out ├── test49.sh ├── test5.out ├── test5.sh ├── test50.out ├── test50.sh ├── test51.out ├── test51.sh ├── test52.out ├── test52.sh ├── test53.out ├── test53.sh ├── test54.out ├── test54.sh ├── test55.out ├── test55.sh ├── test56.out ├── test56.sh ├── test57.out ├── test57.sh ├── test58.out ├── test58.sh ├── test59.out ├── test59.sh ├── test6.out ├── test6.sh ├── test60.out ├── test60.sh ├── test61.out ├── test61.sh ├── test62.out ├── test62.sh ├── test63.out ├── test63.sh ├── test64.out ├── test64.sh ├── test65.out ├── test65.sh ├── test66.out ├── test66.sh ├── test67.out ├── test67.sh ├── test68.out ├── test68.sh ├── test69.out ├── test69.sh ├── test7.out ├── test7.sh ├── test70.out ├── test70.sh ├── test71.out ├── test71.sh ├── test72.out ├── test72.sh ├── test73.out ├── test73.sh ├── test74.out ├── test74.sh ├── test75.out ├── test75.sh ├── test76.out ├── test76.sh ├── test77.out ├── test77.sh ├── test78.out ├── test78.sh ├── test79.out ├── test79.sh ├── test8.out ├── test8.sh ├── test80.out ├── test80.sh ├── test81.out ├── test81.sh ├── test82.out ├── test82.sh ├── test83.out ├── test83.sh ├── test84.out ├── test84.sh ├── test85.out ├── test85.sh ├── test86.out ├── test86.sh ├── test87.out ├── test87.sh ├── test88.out ├── test88.sh ├── test89.out ├── test89.sh ├── test9.out ├── test9.sh ├── test90.out ├── test90.sh ├── test91.out ├── test91.sh └── testCheck.sh /.gitignore: -------------------------------------------------------------------------------- 1 | *# 2 | *.gcda 3 | *.gcno 4 | *.in 5 | *.o 6 | *.orig 7 | *.pyc 8 | *~ 9 | Makefile 10 | aclocal.m4 11 | autom4te.cache/ 12 | build/ 13 | config.log 14 | config.status 15 | config/Makefile 16 | config/Makefile.in 17 | config/config.h* 18 | config/stamp-h1 19 | config/test-driver 20 | configure 21 | cov/ 22 | docs/Doxyfile 23 | docs/html/ 24 | examples/.deps/ 25 | examples/test[0-9] 26 | examples/test[0-9][0-9] 27 | tclap.pc 28 | tests/test*.log 29 | tests/test*.trs 30 | tests/tmp.out 31 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | 2 | original author: Michael E. Smoot 3 | invaluable contributions: Daniel Aarno 4 | more contributions: Erik Zeek 5 | more contributions: Fabien Carmagnac (Tinbergen-AM) 6 | outstanding editing: Carol Smoot 7 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.7) 2 | 3 | project(TCLAP VERSION 1.2.2) 4 | 5 | set(CMAKE_CXX_STANDARD 98) 6 | set(CMAKE_CXX_STANDARD_REQUIRED True) 7 | 8 | add_subdirectory(examples) 9 | -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | 2 | 3 | Copyright (c) 2003 Michael E. Smoot 4 | Copyright (c) 2004 Daniel Aarno 5 | Copyright (c) 2017 Google Inc. 6 | 7 | Permission is hereby granted, free of charge, to any person 8 | obtaining a copy of this software and associated documentation 9 | files (the "Software"), to deal in the Software without restriction, 10 | including without limitation the rights to use, copy, modify, merge, 11 | publish, distribute, sublicense, and/or sell copies of the Software, 12 | and to permit persons to whom the Software is furnished to do so, 13 | subject to the following conditions: 14 | 15 | The above copyright notice and this permission notice shall be 16 | included in all copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 19 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 20 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 21 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 22 | BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 23 | AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR 24 | IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | THE SOFTWARE. 26 | 27 | 28 | -------------------------------------------------------------------------------- /Makefile.am: -------------------------------------------------------------------------------- 1 | 2 | ACLOCAL_AMFLAGS = -I config 3 | 4 | SUBDIRS = include examples docs tests msc config 5 | 6 | pkgconfigdir = $(libdir)/pkgconfig 7 | pkgconfig_DATA = $(PACKAGE).pc 8 | EXTRA_DIST = $(PACKAGE).pc.in 9 | 10 | DISTCLEANFILES = $(PACKAGE).pc 11 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | TCLAP - Templatized Command Line Argument Parser 2 | 3 | This is a simple C++ library that facilitates parsing command line 4 | arguments in a type independent manner. It doesn't conform exactly 5 | to either the GNU or POSIX standards, although it is close. See 6 | docs/manual.html for descriptions of how things work or look at the 7 | simple examples in the examples dir. 8 | 9 | To find out what the latest changes are read the NEWS file in this 10 | directory. 11 | 12 | Any and all feedback is welcome at https://sf.net/p/tclap/discussion/ 13 | -------------------------------------------------------------------------------- /autotools.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | echo "Using autotools versions:" 4 | if [[ -e /usr/bin/autoconf-2.5x && -e /usr/bin/automake-1.7 ]] 5 | then 6 | autoconf-2.5x --version | grep autoconf 7 | automake-1.7 --version | grep automake 8 | aclocal-1.7 -I config 9 | autoconf-2.5x 10 | autoheader-2.5x 11 | automake-1.7 -a 12 | else 13 | autoconf --version | grep autoconf 14 | automake --version | grep automake 15 | aclocal -I config 16 | autoconf 17 | autoheader 18 | automake -a 19 | fi 20 | -------------------------------------------------------------------------------- /config/Makefile.am: -------------------------------------------------------------------------------- 1 | 2 | EXTRA_DIST = ac_cxx_have_sstream.m4\ 3 | ac_cxx_have_strstream.m4\ 4 | ac_cxx_namespaces.m4\ 5 | bb_enable_doxygen.m4 6 | 7 | 8 | -------------------------------------------------------------------------------- /config/ac_cxx_have_long_long.m4: -------------------------------------------------------------------------------- 1 | dnl @synopsis AC_CXX_HAVE_LONG_LONG 2 | dnl 3 | dnl If the C++ implementation have a long long type 4 | dnl 5 | AC_DEFUN([AC_CXX_HAVE_LONG_LONG], 6 | [AC_LANG_SAVE 7 | AC_LANG_CPLUSPLUS 8 | AC_TRY_COMPILE([],[long long x = 1; return 0;], 9 | ac_cv_cxx_have_long_long=yes, ac_cv_cxx_have_long_long=no) 10 | 11 | if test "$ac_cv_cxx_have_long_long" = yes; then 12 | AC_DEFINE(HAVE_LONG_LONG, 1, 13 | [define if the C++ implementation have long long]) 14 | else 15 | AC_DEFINE(HAVE_LONG_LONG, 0, 16 | [define if the C++ implementation have long long]) 17 | fi 18 | AC_LANG_RESTORE 19 | ]) 20 | -------------------------------------------------------------------------------- /config/ac_cxx_have_sstream.m4: -------------------------------------------------------------------------------- 1 | dnl @synopsis AC_CXX_HAVE_SSTREAM 2 | dnl 3 | dnl If the C++ library has a working stringstream, define HAVE_SSTREAM. 4 | dnl 5 | dnl @author Ben Stanley 6 | dnl @version $Id: ac_cxx_have_sstream.m4,v 1.2 2006/02/22 02:10:28 zeekec Exp $ 7 | dnl 8 | AC_DEFUN([AC_CXX_HAVE_SSTREAM], 9 | [AC_REQUIRE([AC_CXX_NAMESPACES]) 10 | AC_LANG_SAVE 11 | AC_LANG_CPLUSPLUS 12 | AC_CHECK_HEADERS(sstream) 13 | AC_CACHE_CHECK([whether the STL defines stringstream], 14 | [ac_cv_cxx_have_sstream], 15 | [AC_TRY_COMPILE([#include 16 | #ifdef HAVE_NAMESPACES 17 | using namespace std; 18 | #endif],[stringstream message; message << "Hello"; return 0;], 19 | ac_cv_cxx_have_sstream=yes, ac_cv_cxx_have_sstream=no) 20 | ]) 21 | if test "$ac_cv_cxx_have_sstream" = yes; then 22 | AC_DEFINE(HAVE_SSTREAM,1,[define if the compiler has stringstream]) 23 | fi 24 | AC_LANG_RESTORE 25 | ]) 26 | -------------------------------------------------------------------------------- /config/ac_cxx_have_strstream.m4: -------------------------------------------------------------------------------- 1 | dnl @synopsis AC_CXX_HAVE_STRSTREAM 2 | dnl 3 | dnl If the C++ library has a working strstream, define HAVE_CLASS_STRSTREAM. 4 | dnl 5 | dnl Adapted from ac_cxx_have_sstream.m4 by Steve Robbins 6 | dnl 7 | AC_DEFUN([AC_CXX_HAVE_STRSTREAM], 8 | [AC_REQUIRE([AC_CXX_NAMESPACES]) 9 | AC_LANG_SAVE 10 | AC_LANG_CPLUSPLUS 11 | AC_CHECK_HEADERS(strstream) 12 | AC_CACHE_CHECK([whether the STL defines strstream], 13 | [ac_cv_cxx_have_class_strstream], 14 | [AC_TRY_COMPILE([#if HAVE_STRSTREAM 15 | # include 16 | #else 17 | # include 18 | #endif 19 | #ifdef HAVE_NAMESPACES 20 | using namespace std; 21 | #endif],[ostrstream message; message << "Hello"; return 0;], 22 | ac_cv_cxx_have_class_strstream=yes, ac_cv_cxx_have_class_strstream=no) 23 | ]) 24 | if test "$ac_cv_cxx_have_class_strstream" = yes; then 25 | AC_DEFINE(HAVE_CLASS_STRSTREAM,1,[define if the library defines strstream]) 26 | fi 27 | AC_LANG_RESTORE 28 | ]) 29 | -------------------------------------------------------------------------------- /config/ac_cxx_namespaces.m4: -------------------------------------------------------------------------------- 1 | dnl @synopsis AC_CXX_NAMESPACES 2 | dnl 3 | dnl If the compiler can prevent names clashes using namespaces, define 4 | dnl HAVE_NAMESPACES. 5 | dnl 6 | dnl @version $Id: ac_cxx_namespaces.m4,v 1.1 2003/03/19 02:40:00 mes5k Exp $ 7 | dnl @author Luc Maisonobe 8 | dnl 9 | AC_DEFUN([AC_CXX_NAMESPACES], 10 | [AC_CACHE_CHECK(whether the compiler implements namespaces, 11 | ac_cv_cxx_namespaces, 12 | [AC_LANG_SAVE 13 | AC_LANG_CPLUSPLUS 14 | AC_TRY_COMPILE([namespace Outer { namespace Inner { int i = 0; }}], 15 | [using namespace Outer::Inner; return i;], 16 | ac_cv_cxx_namespaces=yes, ac_cv_cxx_namespaces=no) 17 | AC_LANG_RESTORE 18 | ]) 19 | if test "$ac_cv_cxx_namespaces" = yes; then 20 | AC_DEFINE(HAVE_NAMESPACES,1,[define to 1 if the compiler implements namespaces]) 21 | fi 22 | ]) 23 | -------------------------------------------------------------------------------- /config/ac_cxx_warn_effective_cxx.m4: -------------------------------------------------------------------------------- 1 | dnl HAVE_WARN_EFFECTIVE_CXX 2 | dnl ---------------------- 3 | dnl 4 | dnl If the C++ compiler accepts the `-Weffc++' flag, 5 | dnl set output variable `WARN_EFFECTIVE_CXX' to `-Weffc++' and 6 | dnl `WARN_NO_EFFECTIVE_CXX' to `-Wno-effc++'. Otherwise, 7 | dnl leave both empty. 8 | dnl 9 | AC_DEFUN([HAVE_WARN_EFFECTIVE_CXX], 10 | [ 11 | AC_REQUIRE([AC_PROG_CXX]) 12 | AC_MSG_CHECKING([whether the C++ compiler (${CXX}) accepts -Weffc++]) 13 | AC_CACHE_VAL([_cv_warn_effective_cxx], 14 | [ 15 | AC_LANG_SAVE 16 | AC_LANG_CPLUSPLUS 17 | save_cxxflags="$CXXFLAGS" 18 | CXXFLAGS="$CXXFLAGS -Weffc++" 19 | AC_TRY_COMPILE([],[main();], 20 | [_cv_warn_effective_cxx=yes], [_cv_warn_effective_cxx=no]) 21 | CXXFLAGS="$save_cxxflags" 22 | AC_LANG_RESTORE 23 | ]) 24 | AC_MSG_RESULT([$_cv_warn_effective_cxx]) 25 | if test "$_cv_warn_effective_cxx" = yes; then 26 | WARN_EFFECTIVE_CXX=-Weffc++ 27 | WARN_NO_EFFECTIVE_CXX=-Wno-effc++ 28 | fi 29 | AC_SUBST([WARN_EFFECTIVE_CXX]) 30 | AC_SUBST([WARN_NO_EFFECTIVE_CXX]) 31 | ]) 32 | -------------------------------------------------------------------------------- /config/bb_enable_doxygen.m4: -------------------------------------------------------------------------------- 1 | AC_DEFUN([BB_ENABLE_DOXYGEN], 2 | [ 3 | AC_ARG_ENABLE(doxygen, [--enable-doxygen enable documentation generation with doxygen (auto)]) 4 | if test "x$enable_doxygen" = xno; then 5 | enable_doc=no 6 | else 7 | AC_PATH_PROG(DOXYGEN, doxygen, , $PATH) 8 | if test x$DOXYGEN = x; then 9 | if test "x$enable_doxygen" = xyes; then 10 | AC_MSG_ERROR([could not find doxygen]) 11 | fi 12 | enable_doc=no 13 | else 14 | enable_doc=yes 15 | fi 16 | fi 17 | AM_CONDITIONAL(DOC, test x$enable_doc = xyes) 18 | ]) 19 | -------------------------------------------------------------------------------- /config/mkinstalldirs: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # mkinstalldirs --- make directory hierarchy 3 | # Author: Noah Friedman 4 | # Created: 1993-05-16 5 | # Public domain 6 | 7 | # $Id: mkinstalldirs,v 1.1 2003/04/03 18:13:41 mes5k Exp $ 8 | 9 | errstatus=0 10 | 11 | for file 12 | do 13 | set fnord `echo ":$file" | sed -ne 's/^:\//#/;s/^://;s/\// /g;s/^#/\//;p'` 14 | shift 15 | 16 | pathcomp= 17 | for d 18 | do 19 | pathcomp="$pathcomp$d" 20 | case "$pathcomp" in 21 | -* ) pathcomp=./$pathcomp ;; 22 | esac 23 | 24 | if test ! -d "$pathcomp"; then 25 | echo "mkdir $pathcomp" 26 | 27 | mkdir "$pathcomp" || lasterr=$? 28 | 29 | if test ! -d "$pathcomp"; then 30 | errstatus=$lasterr 31 | fi 32 | fi 33 | 34 | pathcomp="$pathcomp/" 35 | done 36 | done 37 | 38 | exit $errstatus 39 | 40 | # mkinstalldirs ends here 41 | -------------------------------------------------------------------------------- /configure.ac: -------------------------------------------------------------------------------- 1 | AC_INIT(Makefile.am) 2 | #AC_PREREQ(2.50) 3 | AC_CONFIG_AUX_DIR(config) 4 | AM_CONFIG_HEADER(config/config.h) 5 | AM_INIT_AUTOMAKE(tclap,1.2.2) 6 | AC_PROG_CXX 7 | AC_CXX_HAVE_SSTREAM 8 | AC_CXX_HAVE_STRSTREAM 9 | AC_CXX_HAVE_LONG_LONG 10 | AC_CHECK_PROG(DOT,dot,YES,NO) 11 | AC_PROG_RANLIB 12 | AC_PROG_INSTALL 13 | BB_ENABLE_DOXYGEN 14 | 15 | HAVE_WARN_EFFECTIVE_CXX 16 | CXXFLAGS="$CXXFLAGS $WARN_EFFECTIVE_CXX" 17 | 18 | AM_CONDITIONAL([HAVE_GNU_COMPILERS], [test x$ac_cv_cxx_compiler_gnu = xyes]) 19 | 20 | AC_OUTPUT([ Makefile \ 21 | tclap.pc \ 22 | examples/Makefile \ 23 | include/Makefile \ 24 | include/tclap/Makefile \ 25 | config/Makefile \ 26 | docs/Makefile \ 27 | docs/Doxyfile \ 28 | msc/Makefile \ 29 | msc/examples/Makefile \ 30 | tests/Makefile], \ 31 | [chmod a+x $ac_top_srcdir/tests/*.sh]) 32 | -------------------------------------------------------------------------------- /docs/Makefile.am: -------------------------------------------------------------------------------- 1 | 2 | if DOC 3 | 4 | all: 5 | @DOXYGEN@ Doxyfile 6 | 7 | manual: manual.xml 8 | xsltproc -o manual.html --stringparam html.stylesheet style.css /usr/share/xml/docbook/stylesheet/docbook-xsl/html/docbook.xsl manual.xml 9 | 10 | else 11 | 12 | all: 13 | 14 | endif 15 | 16 | EXTRA_DIST = manual.xml 17 | dist_doc_DATA = index.html manual.html style.css 18 | docdir = ${datadir}/doc/${PACKAGE} 19 | 20 | install-data-local : 21 | $(mkdir_p) $(DESTDIR)$(docdir) 22 | cp -R $(abs_srcdir)/html $(DESTDIR)$(docdir) 23 | 24 | uninstall-local : 25 | chmod -R o+w $(DESTDIR)$(docdir) 26 | rm -rf $(DESTDIR)$(docdir) 27 | 28 | dist-hook : 29 | $(mkdir_p) $(distdir) 30 | cp -R $(abs_srcdir)/html $(distdir) 31 | 32 | clean-local: 33 | $(RM) -rf $(abs_builddir)/html/* 34 | $(RM) -rf $(abs_builddir)/doxygen_sqlite3.db 35 | 36 | -------------------------------------------------------------------------------- /docs/README: -------------------------------------------------------------------------------- 1 | 2 | To generate the manual from the docbook xml you need and xslt processor 3 | and an xsl file that defines the output. For example: 4 | 5 | xsltproc --stringparam html.stylesheet style.css /usr/share/xml/docbook/stylesheet/docbook-xsl/html/docbook.xsl manual.xml > manual.html 6 | -------------------------------------------------------------------------------- /docs/build.html: -------------------------------------------------------------------------------- 1 | 20 | 22 | 23 | 24 | tclap -- Templatized C++ Command Line Parser Library (build status) 25 | 26 | 27 | 28 |

Latest Build Status

29 | Windows build status Windows
31 | 32 | Linux build status Linux
34 | 35 | Mac build status Mac
37 | 38 |

CI Dashboard

39 | 40 | 41 | -------------------------------------------------------------------------------- /docs/index.html: -------------------------------------------------------------------------------- 1 | 20 | 22 | 23 | 24 | 26 | tclap -- Templatized C++ Command Line Parser Library 27 | 28 | 29 | 30 | 31 | 32 | 35 | 38 | 39 |
33 |

Templatized C++ Command Line Parser Library

34 |
36 | Get Templatized C++ Command Line Parser at SourceForge.net. Fast, secure and Free Open Source software downloads 37 |
40 | 51 |
52 | 53 |

54 | TCLAP is a small, flexible library that provides a simple interface for 55 | defining and accessing command line arguments. It was intially 56 | inspired by the user friendly CLAP libary. The 58 | difference is that this library is templatized, so the argument 59 | class is type independent. Type independence avoids identical-except-for-type 60 | objects, such as IntArg, FloatArg, and StringArg. While the library is 61 | not strictly compliant with the GNU or POSIX standards, it is 62 | close. 63 |

64 | 65 |

66 | TCLAP is written in ANSI C++ and is meant to be compatible with any 67 | standards-compliant C++ compiler. It is known to work on Linux, MacOS X, 68 | Windows, and Solaris platforms. The library is implemented 69 | entirely in header files making it easy to use and distribute with other 70 | software. It is licensed under the 71 | MIT License 72 | for worry free distribution. 73 |

74 |

75 | TCLAP is now a mature, stable, and feature rich package. 76 | Unless I get really bored, it probably won't see much further 77 | development aside from bug fixes and compatibility updates. 78 | Please don't let any apparent project inactivity discourage you 79 | from using the software! 80 |

81 |

82 | Don't hesitate to 83 | send us your feedback! 84 |

85 | 86 |

87 | Happy coding! 88 |

89 |
90 | 91 | 92 | 93 | -------------------------------------------------------------------------------- /docs/manual.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mirror/tclap/8b35dd1c23922231ec2dcb95edea0285189de039/docs/manual.html -------------------------------------------------------------------------------- /docs/style.css: -------------------------------------------------------------------------------- 1 | /* 2 | color:#ffffff; white 3 | color:#e0e0e0; light gray 4 | color:#f8f8f8; light gray 5 | color:#003366; dark blue 6 | color:#555555; gray 7 | color:#ff9933; light orange 8 | color:#cc3300; red/brown/orange 9 | color:#660066; purple 10 | color:#669900; green 11 | */ 12 | 13 | a { 14 | color:#003366; 15 | text-decoration:underline; 16 | } 17 | 18 | a:hover { 19 | color:#ff9933; 20 | } 21 | 22 | body { 23 | font-family: verdana, tahoma, helvetica, arial, sans-serif; 24 | font-size: 90%; 25 | background-color:#ffffff; 26 | margin: 1em; 27 | } 28 | 29 | pre { 30 | font-family: courier, serif; 31 | background-color:#f8f8f8; 32 | margin: 1.5em; 33 | font-size:90%; 34 | } 35 | 36 | ul { 37 | list-style: circle outside; 38 | font-stretch:extra-expanded; 39 | /* font-size:90%;*/ 40 | } 41 | 42 | ul.menu { /* inherits from ul */ 43 | padding-left: 1em; 44 | } 45 | 46 | 47 | em { 48 | color:#ff9933; 49 | font-size:110%; 50 | } 51 | 52 | h1,h2,h3{ 53 | color:#ff9933; 54 | } 55 | 56 | h1 { 57 | border-color:#d0d0d0; 58 | border-style:solid; 59 | border-width:1px; 60 | font-weight:bold; 61 | padding: 0.2em; 62 | background-color:#f8f8f8 63 | } 64 | 65 | h2 { 66 | font-size:120%; 67 | font-weight:bold; 68 | border-bottom-style:solid; 69 | border-bottom-width:1px; 70 | border-bottom-color:#d0d0d0; 71 | } 72 | 73 | h3 { 74 | font-size:110%; 75 | font-weight:bold; 76 | font-style:italic; 77 | } 78 | 79 | tt { 80 | font-family: courier, serif; 81 | } 82 | 83 | tt.classname { 84 | font-weight:bold; 85 | } 86 | 87 | tt.constant { 88 | font-weight:bold; 89 | } 90 | 91 | 92 | p { 93 | line-height: 1.5em; 94 | } 95 | 96 | 97 | div.links{ 98 | float: left; 99 | clear: left; 100 | width: 12em; 101 | background-color:#f8f8f8; 102 | border-style:solid; 103 | border-width:1px; 104 | border-color:#d0d0d0; 105 | margin-bottom: 0.5em; 106 | padding: 0.5em 0.5em 0.5em 0.5em; 107 | margin: 0.5em 0.5em 0em 0em; 108 | } 109 | 110 | div.main{ 111 | border-style:solid; 112 | border-width:1px; 113 | border-color:#d0d0d0; 114 | margin: 0.5em 0em 0.5em 14em; 115 | padding: 0.5em 0.5em 0.5em 0.5em; 116 | } 117 | 118 | -------------------------------------------------------------------------------- /docs/upload.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -x 4 | 5 | rsync -aP html index.html manual.html style.css build.html \ 6 | $USER@web.sourceforge.net:/home/project-web/tclap/htdocs 7 | -------------------------------------------------------------------------------- /examples/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | SET( CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG "${OUTPUT_DIRECTORY}") 2 | SET( CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE "${OUTPUT_DIRECTORY}") 3 | 4 | SET(gcc_like_cxx "$,$,$,$>") 5 | SET(msvc_cxx "$") 6 | 7 | function(default_opts target) 8 | target_compile_options(${target} PRIVATE 9 | "$<${gcc_like_cxx}:$>" 10 | "$<${msvc_cxx}:$>" 11 | ) 12 | endfunction(default_opts) 13 | 14 | function(add_example name) 15 | add_executable(${name} ${ARGN}) 16 | target_include_directories(${name} PUBLIC ../include/ ${PROJECT_BINARY_DIR}) 17 | default_opts(${name}) 18 | endfunction() 19 | 20 | # Check we don't define any hard symbols in the headers 21 | add_example(test-hard test-hard-1.cpp test-hard-2.cpp) 22 | 23 | file(GLOB TEST_FILES test[0-9]*.cpp) 24 | foreach(file ${TEST_FILES}) 25 | get_filename_component(file_basename ${file} NAME_WE) 26 | add_example(${file_basename} ${file}) 27 | endforeach() 28 | -------------------------------------------------------------------------------- /examples/Makefile.am: -------------------------------------------------------------------------------- 1 | 2 | noinst_PROGRAMS = test1 test2 test3 test4 test5 test6 test7 test8 test9 \ 3 | test10 test11 test12 test13 test14 test15 test16 \ 4 | test17 test18 test19 test20 test21 test22 test23 test24 \ 5 | test25 test26 test27 test28 test29 test30 6 | 7 | test1_SOURCES = test1.cpp 8 | test2_SOURCES = test2.cpp 9 | test3_SOURCES = test3.cpp 10 | test4_SOURCES = test4.cpp 11 | test5_SOURCES = test5.cpp 12 | test6_SOURCES = test6.cpp 13 | test7_SOURCES = test7.cpp 14 | test8_SOURCES = test8.cpp 15 | test9_SOURCES = test9.cpp 16 | test10_SOURCES = test10.cpp 17 | test11_SOURCES = test11.cpp 18 | test12_SOURCES = test12.cpp 19 | test13_SOURCES = test13.cpp 20 | test14_SOURCES = test14.cpp 21 | test15_SOURCES = test15.cpp 22 | test16_SOURCES = test16.cpp 23 | test17_SOURCES = test-hard-1.cpp test-hard-2.cpp 24 | test18_SOURCES = test18.cpp 25 | test19_SOURCES = test19.cpp 26 | test20_SOURCES = test20.cpp 27 | test21_SOURCES = test21.cpp 28 | test22_SOURCES = test22.cpp 29 | test23_SOURCES = test23.cpp 30 | test24_SOURCES = test24.cpp 31 | test25_SOURCES = test25.cpp 32 | test26_SOURCES = test26.cpp 33 | test27_SOURCES = test27.cpp 34 | test28_SOURCES = test28.cpp 35 | test29_SOURCES = test29.cpp 36 | test30_SOURCES = test30.cpp 37 | 38 | AM_CPPFLAGS = -I$(top_srcdir)/include 39 | 40 | if HAVE_GNU_COMPILERS 41 | AM_CXXFLAGS = -Wall -Wextra 42 | endif 43 | -------------------------------------------------------------------------------- /examples/test-hard-1.cpp: -------------------------------------------------------------------------------- 1 | // -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*- 2 | 3 | #include 4 | -------------------------------------------------------------------------------- /examples/test-hard-2.cpp: -------------------------------------------------------------------------------- 1 | // -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*- 2 | 3 | #include 4 | 5 | int main() { } 6 | -------------------------------------------------------------------------------- /examples/test1.cpp: -------------------------------------------------------------------------------- 1 | // -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*- 2 | 3 | #include 4 | #include 5 | #include 6 | #include "tclap/CmdLine.h" 7 | 8 | using namespace TCLAP; 9 | using namespace std; 10 | 11 | int main(int argc, char** argv) 12 | { 13 | // Wrap everything in a try block. Do this every time, 14 | // because exceptions will be thrown for problems. 15 | try { 16 | 17 | // Define the command line object. 18 | CmdLine cmd("Command description message", ' ', "0.9"); 19 | 20 | // Define a value argument and add it to the command line. 21 | ValueArg nameArg("n","name","Name to print",true,"homer","string"); 22 | cmd.add( nameArg ); 23 | 24 | // Define a switch and add it to the command line. 25 | SwitchArg reverseSwitch("r","reverse","Print name backwards", false); 26 | cmd.add( reverseSwitch ); 27 | 28 | // Parse the args. 29 | cmd.parse( argc, argv ); 30 | 31 | // Get the value parsed by each arg. 32 | string name = nameArg.getValue(); 33 | bool reverseName = reverseSwitch.getValue(); 34 | 35 | // Do what you intend too... 36 | if ( reverseName ) 37 | { 38 | reverse(name.begin(),name.end()); 39 | cout << "My name (spelled backwards) is: " << name << endl; 40 | } 41 | else 42 | cout << "My name is: " << name << endl; 43 | 44 | 45 | } catch (ArgException &e) // catch any exceptions 46 | { cerr << "error: " << e.error() << " for arg " << e.argId() << endl; } 47 | } 48 | 49 | -------------------------------------------------------------------------------- /examples/test10.cpp: -------------------------------------------------------------------------------- 1 | // -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*- 2 | 3 | // Test only makes sure we can use different argv types for the 4 | // parser. Don't run, just compile. 5 | 6 | #include "tclap/CmdLine.h" 7 | 8 | using namespace TCLAP; 9 | int main() 10 | { 11 | char *argv5[] = {(char*)"Foo", 0}; 12 | const char *argv6[] = {"Foo", 0}; 13 | const char * const argv7[] = {"Foo", 0}; 14 | char **argv1 = argv5; 15 | const char **argv2 = argv6; 16 | const char * const * argv3 = argv7; 17 | const char * const * const argv4 = argv7; 18 | 19 | CmdLine cmd("Command description message", ' ', "0.9"); 20 | cmd.parse(0, argv1); 21 | cmd.parse(0, argv2); 22 | cmd.parse(0, argv3); 23 | cmd.parse(0, argv4); 24 | cmd.parse(0, argv5); 25 | cmd.parse(0, argv6); 26 | cmd.parse(0, argv7); 27 | } 28 | 29 | -------------------------------------------------------------------------------- /examples/test11.cpp: -------------------------------------------------------------------------------- 1 | // -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*- 2 | 3 | #include "tclap/CmdLine.h" 4 | #include 5 | 6 | #include 7 | 8 | using namespace TCLAP; 9 | 10 | // Define a simple 3D vector type 11 | struct Vect3D { 12 | double v[3]; 13 | 14 | // operator= will be used to assign to the vector 15 | Vect3D& operator=(const std::string &str) 16 | { 17 | std::istringstream iss(str); 18 | if (!(iss >> v[0] >> v[1] >> v[2])) 19 | throw TCLAP::ArgParseException(str + " is not a 3D vector"); 20 | 21 | return *this; 22 | } 23 | 24 | std::ostream& print(std::ostream &os) const 25 | { 26 | std::copy(v, v + 3, std::ostream_iterator(os, " ")); 27 | return os; 28 | } 29 | }; 30 | 31 | // Create an ArgTraits for the 3D vector type that declares it to be 32 | // of string like type 33 | namespace TCLAP { 34 | template<> 35 | struct ArgTraits { 36 | typedef StringLike ValueCategory; 37 | }; 38 | } 39 | 40 | int main(int argc, char *argv[]) 41 | { 42 | CmdLine cmd("Command description message", ' ', "0.9"); 43 | ValueArg vec("v", "vect", "vector", 44 | true, Vect3D(), "3D vector", cmd); 45 | 46 | try { 47 | cmd.parse(argc, argv); 48 | } catch(std::exception &e) { 49 | std::cout << e.what() << std::endl; 50 | return EXIT_FAILURE; 51 | } 52 | 53 | vec.getValue().print(std::cout); 54 | std::cout << std::endl; 55 | } 56 | 57 | -------------------------------------------------------------------------------- /examples/test12.cpp: -------------------------------------------------------------------------------- 1 | // -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*- 2 | 3 | #include "tclap/CmdLine.h" 4 | #include 5 | #include 6 | 7 | #include 8 | 9 | using namespace TCLAP; 10 | 11 | // Define a simple 3D vector type 12 | struct Vect3D { 13 | double v[3]; 14 | 15 | // operator= will be used to assign to the vector 16 | Vect3D& operator=(const std::string &str) 17 | { 18 | std::istringstream iss(str); 19 | if (!(iss >> v[0] >> v[1] >> v[2])) 20 | throw TCLAP::ArgParseException(str + " is not a 3D vector"); 21 | 22 | return *this; 23 | } 24 | 25 | std::ostream& print(std::ostream &os) const 26 | { 27 | std::copy(v, v + 3, std::ostream_iterator(os, " ")); 28 | return os; 29 | } 30 | 31 | }; 32 | 33 | std::ostream& operator<<(std::ostream &os, const Vect3D &v) 34 | { 35 | return v.print(os); 36 | } 37 | 38 | // Create an ArgTraits for the 3D vector type that declares it to be 39 | // of string like type 40 | namespace TCLAP { 41 | template<> 42 | struct ArgTraits { 43 | typedef StringLike ValueCategory; 44 | }; 45 | } 46 | 47 | int main(int argc, char *argv[]) 48 | { 49 | CmdLine cmd("Command description message", ' ', "0.9"); 50 | MultiArg vec("v", "vect", "vector", 51 | true, "3D vector", cmd); 52 | 53 | try { 54 | cmd.parse(argc, argv); 55 | } catch(std::exception &e) { 56 | std::cout << e.what() << std::endl; 57 | return EXIT_FAILURE; 58 | } 59 | 60 | std::copy(vec.begin(), vec.end(), 61 | std::ostream_iterator(std::cout, "\n")); 62 | 63 | std::cout << "REVERSED" << std::endl; 64 | 65 | // use alt. form getValue() 66 | std::vector v(vec.getValue()); 67 | std::reverse(v.begin(), v.end()); 68 | 69 | std::copy(v.begin(), v.end(), 70 | std::ostream_iterator(std::cout, "\n")); 71 | } 72 | 73 | -------------------------------------------------------------------------------- /examples/test13.cpp: -------------------------------------------------------------------------------- 1 | // -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*- 2 | 3 | #include 4 | #include 5 | 6 | #include 7 | 8 | using namespace TCLAP; 9 | 10 | // 11 | // This file tests that we can parse args from a vector 12 | // of strings rather than argv. This also tests a bug 13 | // where a single element in the vector contains both 14 | // the flag and value AND the value contains the flag 15 | // from another switch arg. This would fool the parser 16 | // into thinking that the string was a combined switches 17 | // string rather than a flag value combo. 18 | // 19 | // This should not print an error 20 | // 21 | // Contributed by Nico Lugil. 22 | // 23 | int main() 24 | { 25 | 26 | try 27 | { 28 | CmdLine cmd("Test", ' ', "not versioned",true); 29 | 30 | MultiArg Arg("X","fli","fli module",false,"string"); 31 | cmd.add(Arg); 32 | MultiSwitchArg ArgMultiSwitch("d","long_d","example"); 33 | cmd.add(ArgMultiSwitch); 34 | 35 | std::vector in; 36 | in.push_back("prog name"); 37 | in.push_back("-X module"); 38 | cmd.parse(in); 39 | 40 | std::vector s = Arg.getValue(); 41 | for(unsigned int i = 0 ; i < s.size() ; i++) 42 | { 43 | std::cout << s[i] << "\n"; 44 | } 45 | std::cout << "MultiSwtichArg was found " << ArgMultiSwitch.getValue() << " times.\n"; 46 | 47 | } 48 | catch (ArgException &e) // catch any exceptions 49 | { 50 | std::cerr << "error: " << e.error() << " for arg " << e.argId() << std::endl; 51 | } 52 | 53 | std::cout << "done...\n"; 54 | 55 | return 0; 56 | } 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /examples/test14.cpp: -------------------------------------------------------------------------------- 1 | // -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*- 2 | 3 | #include "tclap/CmdLine.h" 4 | #include 5 | #include 6 | 7 | #include 8 | 9 | // Define a simple 3D vector type 10 | template 11 | struct Vect : public TCLAP::StringLikeTrait { 12 | //typedef TCLAP::StringLike ValueCategory; 13 | T v[LEN]; 14 | 15 | // operator= will be used to assign to the vector 16 | Vect& operator=(const std::string &str) 17 | { 18 | std::istringstream iss(str); 19 | for (size_t n = 0; n < LEN; n++) { 20 | if (!(iss >> v[n])) { 21 | std::ostringstream oss; 22 | oss << " is not a vector of size " << LEN; 23 | throw TCLAP::ArgParseException(str + oss.str()); 24 | } 25 | } 26 | 27 | if (!iss.eof()) { 28 | std::ostringstream oss; 29 | oss << " is not a vector of size " << LEN; 30 | throw TCLAP::ArgParseException(str + oss.str()); 31 | } 32 | 33 | return *this; 34 | } 35 | 36 | std::ostream& print(std::ostream &os) const 37 | { 38 | std::copy(v, v + LEN, std::ostream_iterator(os, ", ")); 39 | return os; 40 | } 41 | 42 | }; 43 | 44 | int main(int argc, char *argv[]) 45 | { 46 | TCLAP::CmdLine cmd("Command description message", ' ', "0.9"); 47 | TCLAP::ValueArg< Vect > vec("v", "vect", "vector", 48 | true, Vect(), 49 | "3D vector", cmd); 50 | 51 | try { 52 | cmd.parse(argc, argv); 53 | } catch(std::exception &e) { 54 | std::cout << e.what() << std::endl; 55 | return EXIT_FAILURE; 56 | } 57 | 58 | vec.getValue().print(std::cout); 59 | std::cout << std::endl; 60 | } 61 | -------------------------------------------------------------------------------- /examples/test15.cpp: -------------------------------------------------------------------------------- 1 | // -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*- 2 | 3 | #include "tclap/CmdLine.h" 4 | #include 5 | #include 6 | 7 | #include 8 | 9 | // Define a simple 3D vector type 10 | template 11 | struct Vect { 12 | typedef TCLAP::StringLike ValueCategory; 13 | T v[LEN]; 14 | 15 | // operator= will be used to assign to the vector 16 | Vect& operator=(const std::string &str) 17 | { 18 | std::istringstream iss(str); 19 | for (size_t n = 0; n < LEN; n++) { 20 | if (!(iss >> v[n])) { 21 | std::ostringstream oss; 22 | oss << " is not a vector of size " << LEN; 23 | throw TCLAP::ArgParseException(str + oss.str()); 24 | } 25 | } 26 | 27 | if (!iss.eof()) { 28 | std::ostringstream oss; 29 | oss << " is not a vector of size " << LEN; 30 | throw TCLAP::ArgParseException(str + oss.str()); 31 | } 32 | 33 | return *this; 34 | } 35 | 36 | std::ostream& print(std::ostream &os) const 37 | { 38 | std::copy(v, v + LEN, std::ostream_iterator(os, " ")); 39 | return os; 40 | } 41 | 42 | }; 43 | 44 | int main(int argc, char *argv[]) 45 | { 46 | TCLAP::CmdLine cmd("Command description message", ' ', "0.9"); 47 | TCLAP::ValueArg< Vect > vec("v", "vect", "vector", 48 | true, Vect(), 49 | "3D vector", cmd); 50 | 51 | try { 52 | cmd.parse(argc, argv); 53 | } catch(std::exception &e) { 54 | std::cout << e.what() << std::endl; 55 | return EXIT_FAILURE; 56 | } 57 | 58 | vec.getValue().print(std::cout); 59 | std::cout << std::endl; 60 | } 61 | -------------------------------------------------------------------------------- /examples/test16.cpp: -------------------------------------------------------------------------------- 1 | // -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*- 2 | 3 | #include "tclap/CmdLine.h" 4 | #include 5 | #include 6 | 7 | #include 8 | 9 | namespace TCLAP { 10 | template<> 11 | struct ArgTraits< std::vector > { 12 | typedef StringLike ValueCategory; 13 | }; 14 | 15 | template<> 16 | void SetString< std::vector >(std::vector &v, 17 | const std::string &s) 18 | { 19 | std::istringstream iss(s); 20 | while (iss) { 21 | double tmp; 22 | iss >> tmp; 23 | v.push_back(tmp); 24 | } 25 | } 26 | } 27 | 28 | int main(int argc, char *argv[]) 29 | { 30 | TCLAP::CmdLine cmd("Command description message", ' ', "0.9"); 31 | TCLAP::ValueArg< std::vector > vec("v", "vect", "vector", 32 | true, std::vector(), 33 | "3D vector", cmd); 34 | try { 35 | cmd.parse(argc, argv); 36 | } catch(std::exception &e) { 37 | std::cout << e.what() << std::endl; 38 | return EXIT_FAILURE; 39 | } 40 | 41 | const std::vector &v = vec.getValue(); 42 | std::copy(v.begin(), v.end(), 43 | std::ostream_iterator(std::cout, "\n")); 44 | std::cout << std::endl; 45 | } 46 | -------------------------------------------------------------------------------- /examples/test18.cpp: -------------------------------------------------------------------------------- 1 | // -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*- 2 | 3 | #include 4 | #include 5 | #include 6 | #include "tclap/CmdLine.h" 7 | 8 | using namespace TCLAP; 9 | using namespace std; 10 | 11 | int main(int argc, char** argv) 12 | { 13 | try { 14 | 15 | CmdLine cmd("Command description message", ' ', "0.9", true); 16 | 17 | cmd.setExceptionHandling(false); 18 | 19 | cmd.parse(argc, argv); 20 | 21 | } catch (ArgException &e) { // catch any exceptions 22 | cerr << "error: " << e.error() << " for arg " << e.argId() << endl; 23 | return 1; 24 | } catch (ExitException &e) { // catch any exceptions 25 | cerr << "Exiting on ExitException." << endl; 26 | return e.getExitStatus(); 27 | } 28 | } 29 | 30 | -------------------------------------------------------------------------------- /examples/test19.cpp: -------------------------------------------------------------------------------- 1 | // -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*- 2 | 3 | 4 | 5 | #define TCLAP_SETBASE_ZERO 1 6 | 7 | #include "tclap/CmdLine.h" 8 | #include 9 | #include 10 | 11 | 12 | using namespace TCLAP; 13 | using namespace std; 14 | 15 | int main(int argc, char** argv) 16 | { 17 | 18 | try { 19 | 20 | CmdLine cmd("this is a message", ' ', "0.99" ); 21 | 22 | ValueArg itest("i", "intTest", "integer test", true, 5, "int"); 23 | cmd.add( itest ); 24 | 25 | // 26 | // Parse the command line. 27 | // 28 | cmd.parse(argc,argv); 29 | 30 | // 31 | // Set variables 32 | // 33 | int _intTest = itest.getValue(); 34 | cout << "found int: " << _intTest << endl; 35 | 36 | } catch ( ArgException& e ) 37 | { cout << "ERROR: " << e.error() << " " << e.argId() << endl; } 38 | } 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /examples/test2.cpp: -------------------------------------------------------------------------------- 1 | // -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*- 2 | 3 | #include "tclap/CmdLine.h" 4 | #include 5 | #include 6 | 7 | using namespace TCLAP; 8 | using namespace std; 9 | 10 | int _intTest; 11 | float _floatTest; 12 | bool _boolTestA; 13 | bool _boolTestB; 14 | bool _boolTestC; 15 | string _stringTest; 16 | string _utest; 17 | 18 | void parseOptions(int argc, char** argv); 19 | 20 | int main(int argc, char** argv) 21 | { 22 | 23 | parseOptions(argc,argv); 24 | 25 | cout << "for float we got : " << _floatTest << endl 26 | << "for int we got : " << _intTest<< endl 27 | << "for string we got : " << _stringTest<< endl 28 | << "for ulabeled we got : " << _utest << endl 29 | << "for bool A we got : " << _boolTestA << endl 30 | << "for bool B we got : " << _boolTestB << endl 31 | << "for bool C we got : " << _boolTestC << endl; 32 | 33 | } 34 | 35 | 36 | void parseOptions(int argc, char** argv) 37 | { 38 | try { 39 | 40 | CmdLine cmd("this is a message", ' ', "0.99" ); 41 | 42 | // 43 | // Define arguments 44 | // 45 | 46 | SwitchArg btest("B","existTestB", "tests for the existence of B", false); 47 | cmd.add( btest ); 48 | 49 | SwitchArg ctest("C","existTestC", "tests for the existence of C", false); 50 | cmd.add( ctest ); 51 | 52 | SwitchArg atest("A","existTestA", "tests for the existence of A", false); 53 | cmd.add( atest ); 54 | 55 | ValueArg stest("s","stringTest","string test",true,"homer", 56 | "string"); 57 | cmd.add( stest ); 58 | 59 | ValueArg itest("i", "intTest", "integer test", true, 5, "int"); 60 | cmd.add( itest ); 61 | 62 | ValueArg ftest("f", "floatTest", "float test", false, 3.7, "float"); 63 | cmd.add( ftest ); 64 | 65 | UnlabeledValueArg utest("unTest","unlabeld test", true, 66 | "default","string"); 67 | cmd.add( utest ); 68 | 69 | UnlabeledMultiArg mtest("fileName", "file names", false, "string"); 70 | cmd.add( mtest ); 71 | 72 | // 73 | // Parse the command line. 74 | // 75 | cmd.parse(argc,argv); 76 | 77 | // 78 | // Set variables 79 | // 80 | _intTest = itest.getValue(); 81 | _floatTest = ftest.getValue(); 82 | _stringTest = stest.getValue(); 83 | _boolTestB = btest.getValue(); 84 | _boolTestC = ctest.getValue(); 85 | _boolTestA = atest.getValue(); 86 | _utest = utest.getValue(); 87 | 88 | vector v = mtest.getValue(); 89 | for ( int i = 0; static_cast(i) < v.size(); i++ ) 90 | cout << i << " " << v[i] << endl; 91 | 92 | } catch ( ArgException& e ) 93 | { cout << "ERROR: " << e.error() << " " << e.argId() << endl; } 94 | } 95 | 96 | 97 | 98 | -------------------------------------------------------------------------------- /examples/test20.cpp: -------------------------------------------------------------------------------- 1 | // -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*- 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | using namespace TCLAP; 9 | using namespace std; 10 | 11 | int main(int argc, char** argv) 12 | { 13 | // Wrap everything in a try block. Do this every time, 14 | // because exceptions will be thrown for problems. 15 | try { 16 | 17 | // Define the command line object. 18 | CmdLine cmd("Command description message", '=', "0.9"); 19 | 20 | SwitchArg atmcSwitch("a", "atmc", "aContinuous time semantics", false); 21 | SwitchArg btmcSwitch("b", "btmc", "bDiscrete time semantics", false); 22 | cmd.xorAdd(atmcSwitch, btmcSwitch); 23 | 24 | // Parse the args. 25 | cmd.parse( argc, argv ); 26 | 27 | } catch (ArgException &e) // catch any exceptions 28 | { cerr << "error: " << e.error() << " for arg " << e.argId() << endl; } 29 | } 30 | -------------------------------------------------------------------------------- /examples/test21.cpp: -------------------------------------------------------------------------------- 1 | // -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*- 2 | 3 | 4 | // This illustrates how to change the flag and name start strings. 5 | // Note that these defines need to happen *before* tclap is included! 6 | #define TCLAP_NAMESTARTSTRING "~~" 7 | #define TCLAP_FLAGSTARTSTRING "/" 8 | 9 | #include 10 | #include 11 | #include 12 | #include "tclap/CmdLine.h" 13 | 14 | using namespace TCLAP; 15 | using namespace std; 16 | 17 | int main(int argc, char** argv) 18 | { 19 | // Wrap everything in a try block. Do this every time, 20 | // because exceptions will be thrown for problems. 21 | try { 22 | 23 | // Define the command line object. 24 | CmdLine cmd("Command description message", ' ', "0.9"); 25 | 26 | // Define a value argument and add it to the command line. 27 | ValueArg nameArg("n","name","Name to print",true,"homer","string"); 28 | cmd.add( nameArg ); 29 | 30 | // Define a switch and add it to the command line. 31 | SwitchArg reverseSwitch("r","reverse","Print name backwards", false); 32 | cmd.add( reverseSwitch ); 33 | 34 | // Parse the args. 35 | cmd.parse( argc, argv ); 36 | 37 | // Get the value parsed by each arg. 38 | string name = nameArg.getValue(); 39 | bool reverseName = reverseSwitch.getValue(); 40 | 41 | // Do what you intend too... 42 | if ( reverseName ) 43 | { 44 | reverse(name.begin(),name.end()); 45 | cout << "My name (spelled backwards) is: " << name << endl; 46 | } 47 | else 48 | cout << "My name is: " << name << endl; 49 | 50 | 51 | } catch (ArgException &e) // catch any exceptions 52 | { cerr << "error: " << e.error() << " for arg " << e.argId() << endl; } 53 | } 54 | 55 | -------------------------------------------------------------------------------- /examples/test22.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "tclap/CmdLine.h" 5 | 6 | using namespace TCLAP; 7 | using namespace std; 8 | 9 | int main(int argc, char** argv) 10 | { 11 | // Wrap everything in a try block. Do this every time, 12 | // because exceptions will be thrown for problems. 13 | try { 14 | 15 | // Define the command line object. 16 | CmdLine cmd("Command description message", ' ', "0.9"); 17 | cmd.ignoreUnmatched(true); 18 | 19 | // Define a value argument and add it to the command line. 20 | ValueArg nameArg("n","name","Name to print",true,"homer","string"); 21 | cmd.add( nameArg ); 22 | 23 | // Define a switch and add it to the command line. 24 | SwitchArg reverseSwitch("r","reverse","Print name backwards", false); 25 | cmd.add( reverseSwitch ); 26 | 27 | // Parse the args. 28 | cmd.parse( argc, argv ); 29 | 30 | // Get the value parsed by each arg. 31 | string name = nameArg.getValue(); 32 | bool reverseName = reverseSwitch.getValue(); 33 | 34 | // Do what you intend too... 35 | if ( reverseName ) 36 | { 37 | reverse(name.begin(),name.end()); 38 | cout << "My name (spelled backwards) is: " << name << endl; 39 | } 40 | else 41 | cout << "My name is: " << name << endl; 42 | 43 | 44 | } catch (ArgException &e) // catch any exceptions 45 | { cerr << "error: " << e.error() << " for arg " << e.argId() << endl; } 46 | } 47 | 48 | -------------------------------------------------------------------------------- /examples/test23.cpp: -------------------------------------------------------------------------------- 1 | 2 | 3 | #include "tclap/CmdLine.h" 4 | #include 5 | #include 6 | 7 | using namespace TCLAP; 8 | using namespace std; 9 | 10 | bool _boolTestB; 11 | string _stringTest; 12 | string _utest; 13 | string _ztest; 14 | 15 | void parseOptions(int argc, char** argv); 16 | 17 | int main(int argc, char** argv) 18 | { 19 | 20 | parseOptions(argc,argv); 21 | 22 | cout << "for string we got : " << _stringTest<< endl 23 | << "for bool B we got : " << _boolTestB << endl; 24 | 25 | } 26 | 27 | 28 | void parseOptions(int argc, char** argv) 29 | { 30 | try { 31 | 32 | CmdLine cmd("this is a message", '=', "0.99" ); 33 | cmd.ignoreUnmatched(true); 34 | 35 | // 36 | // Define arguments 37 | // 38 | 39 | SwitchArg btest("B","existTestB", "exist Test B", cmd, false); 40 | 41 | ValueArg stest("s", "stringTest", "string test", true, "homer", 42 | "string", cmd ); 43 | 44 | MultiArg itest("i", "intTest", "multi int test", false,"int", cmd ); 45 | 46 | MultiArg ftest("f", "floatTest", "multi float test", false,"float", 47 | cmd ); 48 | 49 | UnlabeledMultiArg mtest("fileName","file names", false, 50 | "fileNameString", cmd); 51 | // 52 | // Parse the command line. 53 | // 54 | cmd.parse(argc,argv); 55 | 56 | 57 | // 58 | // Set variables 59 | // 60 | _stringTest = stest.getValue(); 61 | _boolTestB = btest.getValue(); 62 | 63 | vector vi = itest.getValue(); 64 | for ( int i = 0; static_cast(i) < vi.size(); i++ ) 65 | cout << "[-i] " << i << " " << vi[i] << endl; 66 | 67 | vector vf = ftest.getValue(); 68 | for ( int i = 0; static_cast(i) < vf.size(); i++ ) 69 | cout << "[-f] " << i << " " << vf[i] << endl; 70 | 71 | vector v = mtest.getValue(); 72 | for ( int i = 0; static_cast(i) < v.size(); i++ ) 73 | cout << "[ ] " << i << " " << v[i] << endl; 74 | 75 | } catch ( ArgException& e ) 76 | { cout << "ERROR: " << e.error() << " " << e.argId() << endl; } 77 | } 78 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /examples/test24.cpp: -------------------------------------------------------------------------------- 1 | // -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*- 2 | 3 | // Test various Arg properties such as invalid flag/names 4 | 5 | #include "tclap/CmdLine.h" 6 | 7 | using namespace TCLAP; 8 | using namespace std; 9 | 10 | int main() { 11 | CmdLine cmd("Command description message", ' ', "0.9"); 12 | try { // Argument with two character 'flag' 13 | ValueArg nameArg("nx","name","Name to print",true, 14 | "homer","string"); 15 | return EXIT_FAILURE; 16 | } catch(SpecificationException &e) { 17 | cout << e.what() << std::endl; // Expected 18 | } 19 | 20 | try { // space as flag 21 | ValueArg nameArg(" ","name","Name to print",true, 22 | "homer","string"); 23 | return EXIT_FAILURE; 24 | } catch(SpecificationException &e) { 25 | cout << e.what() << std::endl; // Expected 26 | } 27 | 28 | try { // - as flag 29 | ValueArg nameArg("-","name","Name to print",true, 30 | "homer","string"); 31 | return EXIT_FAILURE; 32 | } catch(SpecificationException &e) { 33 | cout << e.what() << std::endl; // Expected 34 | } 35 | 36 | try { // -- as flag 37 | ValueArg nameArg("--","name","Name to print",true, 38 | "homer","string"); 39 | return EXIT_FAILURE; 40 | } catch(SpecificationException &e) { 41 | cout << e.what() << std::endl; // Expected 42 | } 43 | 44 | try { // space as name 45 | ValueArg nameArg("n"," ","Name to print",true, 46 | "homer","string"); 47 | return EXIT_FAILURE; 48 | } catch(SpecificationException &e) { 49 | cout << e.what() << std::endl; // Expected 50 | } 51 | 52 | try { // - as flag 53 | ValueArg nameArg("n","-","Name to print",true, 54 | "homer","string"); 55 | return EXIT_FAILURE; 56 | } catch(SpecificationException &e) { 57 | cout << e.what() << std::endl; // Expected 58 | } 59 | 60 | try { // -- as flag 61 | ValueArg nameArg("n","--","Name to print",true, 62 | "homer","string"); 63 | return EXIT_FAILURE; 64 | } catch(SpecificationException &e) { 65 | cout << e.what() << std::endl; // Expected 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /examples/test25.cpp: -------------------------------------------------------------------------------- 1 | // -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*- 2 | 3 | #include "tclap/CmdLine.h" 4 | #include "tclap/DocBookOutput.h" 5 | #include "tclap/ZshCompletionOutput.h" 6 | #include 7 | #include 8 | 9 | using namespace TCLAP; 10 | using namespace std; 11 | 12 | int main(int argc, char** argv) 13 | { 14 | CmdLine cmd("this is a message", ' ', "0.99" ); 15 | DocBookOutput docoutput; 16 | ZshCompletionOutput zshoutput; 17 | CmdLineOutput *output = &zshoutput; 18 | 19 | if (argc > 2) 20 | output = &docoutput; 21 | 22 | cmd.setOutput(output); 23 | 24 | SwitchArg btest("B","sB", "exist Test B", false); 25 | MultiArg atest("A","sA", "exist Test A", false, "integer"); 26 | 27 | ValueArg stest("s", "Bs", "string test", true, "homer", 28 | "string"); 29 | 30 | cmd.xorAdd(stest, btest); 31 | cmd.add( atest ); 32 | 33 | cmd.parse(argc,argv); 34 | } 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /examples/test26.cpp: -------------------------------------------------------------------------------- 1 | #include "tclap/CmdLine.h" 2 | #include 3 | 4 | using namespace TCLAP; 5 | 6 | // Define a simple 3D vector type 7 | struct Vect3D { 8 | double v[3]; 9 | 10 | std::ostream& print(std::ostream &os) const 11 | { 12 | std::copy(v, v + 3, std::ostream_iterator(os, " ")); 13 | return os; 14 | } 15 | }; 16 | 17 | // operator>> will be used to assign to the vector since the default 18 | // is that all types are ValueLike. 19 | std::istream &operator>>(std::istream &is, Vect3D &v) 20 | { 21 | if (!(is >> v.v[0] >> v.v[1] >> v.v[2])) 22 | throw TCLAP::ArgParseException(" Argument is not a 3D vector"); 23 | 24 | return is; 25 | } 26 | 27 | int main(int argc, char *argv[]) 28 | { 29 | CmdLine cmd("Command description message", ' ', "0.9"); 30 | ValueArg vec("v", "vect", "vector", 31 | true, Vect3D(), "3D vector", cmd); 32 | 33 | try { 34 | cmd.parse(argc, argv); 35 | } catch(std::exception &e) { 36 | std::cout << e.what() << std::endl; 37 | return EXIT_FAILURE; 38 | } 39 | 40 | vec.getValue().print(std::cout); 41 | std::cout << std::endl; 42 | } 43 | -------------------------------------------------------------------------------- /examples/test27.cpp: -------------------------------------------------------------------------------- 1 | #include "tclap/CmdLine.h" 2 | #include 3 | #include 4 | 5 | using namespace TCLAP; 6 | using namespace std; 7 | 8 | int main(int argc, char** argv) 9 | { 10 | 11 | CmdLine cmd("test arg conversion operator"); 12 | SwitchArg falseSwitch("f","false", "test false condition", cmd, false); 13 | SwitchArg trueSwitch("t","true", "tests true condition", cmd, true); 14 | ValueArg strArg("s","str", "test string arg", false, "defStr", "string", cmd); 15 | ValueArg intArg("i","int", "tests int arg", false, 4711, "integer", cmd); 16 | 17 | cmd.parse(argc, argv); 18 | 19 | string s = strArg; 20 | int i = intArg; 21 | 22 | cout << "for falseSwitch we got : " << falseSwitch << endl 23 | << "for trueSwitch we got : " << trueSwitch << endl 24 | << "for strArg we got : " << s << endl 25 | << "for intArg we got : " << i << endl; 26 | } 27 | -------------------------------------------------------------------------------- /examples/test28.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "tclap/CmdLine.h" 4 | 5 | using namespace TCLAP; 6 | using namespace std; 7 | 8 | int main() 9 | { 10 | try { 11 | CmdLine cmd("test constraint bug"); 12 | ValueArg arg("i","int", "tests int arg", false, 4711, NULL, cmd); 13 | cout << "Expected exception" << endl; 14 | } catch(std::logic_error &e) { /* expected */ } 15 | 16 | try { 17 | CmdLine cmd("test constraint bug"); 18 | ValueArg arg1("i","int", "tests int arg", false, 4711, NULL, NULL); 19 | cout << "Expected exception" << endl; 20 | } catch(std::logic_error &e) { /* expected */ } 21 | 22 | try { 23 | CmdLine cmd("test constraint bug"); 24 | MultiArg arg1("i","int", "tests int arg", false, NULL, NULL); 25 | cout << "Expected exception" << endl; 26 | } catch(std::logic_error &e) { /* expected */ } 27 | 28 | try { 29 | CmdLine cmd("test constraint bug"); 30 | MultiArg arg1("i","int", "tests int arg", false, NULL, cmd); 31 | cout << "Expected exception" << endl; 32 | } catch(std::logic_error &e) { /* expected */ } 33 | 34 | cout << "Passed" << endl; 35 | } 36 | -------------------------------------------------------------------------------- /examples/test29.cpp: -------------------------------------------------------------------------------- 1 | #include "tclap/CmdLine.h" 2 | #include 3 | #include 4 | 5 | using namespace TCLAP; 6 | using namespace std; 7 | 8 | // https://sourceforge.net/p/tclap/bugs/30/ 9 | int main() { 10 | CmdLine cmd("test empty argv"); 11 | std::vector args; 12 | cmd.parse(args); 13 | } 14 | -------------------------------------------------------------------------------- /examples/test3.cpp: -------------------------------------------------------------------------------- 1 | // -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*- 2 | 3 | #include "tclap/CmdLine.h" 4 | #include 5 | #include 6 | 7 | using namespace TCLAP; 8 | using namespace std; 9 | 10 | bool _boolTestB; 11 | string _stringTest; 12 | string _utest; 13 | string _ztest; 14 | 15 | void parseOptions(int argc, char** argv); 16 | 17 | int main(int argc, char** argv) 18 | { 19 | 20 | parseOptions(argc,argv); 21 | 22 | cout << "for string we got : " << _stringTest<< endl 23 | << "for ulabeled one we got : " << _utest << endl 24 | << "for ulabeled two we got : " << _ztest << endl 25 | << "for bool B we got : " << _boolTestB << endl; 26 | 27 | } 28 | 29 | 30 | void parseOptions(int argc, char** argv) 31 | { 32 | try { 33 | 34 | CmdLine cmd("this is a message", '=', "0.99" ); 35 | 36 | // 37 | // Define arguments 38 | // 39 | 40 | SwitchArg btest("B","existTestB", "exist Test B", false); 41 | cmd.add( btest ); 42 | 43 | ValueArg stest("", "stringTest", "string test", true, "homer", 44 | "string"); 45 | cmd.add( stest ); 46 | 47 | UnlabeledValueArg utest("unTest1","unlabeled test one", true, 48 | "default","string"); 49 | cmd.add( utest ); 50 | 51 | UnlabeledValueArg ztest("unTest2","unlabeled test two", true, 52 | "default","string"); 53 | cmd.add( ztest ); 54 | 55 | MultiArg itest("i", "intTest", "multi int test", false,"int" ); 56 | cmd.add( itest ); 57 | 58 | MultiArg ftest("f", "floatTest", "multi float test", false,"float" ); 59 | cmd.add( ftest ); 60 | 61 | UnlabeledMultiArg mtest("fileName","file names",false, 62 | "fileNameString"); 63 | cmd.add( mtest ); 64 | // 65 | // Parse the command line. 66 | // 67 | cmd.parse(argc,argv); 68 | 69 | 70 | // 71 | // Set variables 72 | // 73 | _stringTest = stest.getValue(); 74 | _boolTestB = btest.getValue(); 75 | _utest = utest.getValue(); 76 | _ztest = ztest.getValue(); 77 | 78 | vector vi = itest.getValue(); 79 | for ( int i = 0; static_cast(i) < vi.size(); i++ ) 80 | cout << "[-i] " << i << " " << vi[i] << endl; 81 | 82 | vector vf = ftest.getValue(); 83 | for ( int i = 0; static_cast(i) < vf.size(); i++ ) 84 | cout << "[-f] " << i << " " << vf[i] << endl; 85 | 86 | vector v = mtest.getValue(); 87 | for ( int i = 0; static_cast(i) < v.size(); i++ ) 88 | cout << "[ ] " << i << " " << v[i] << endl; 89 | 90 | } catch ( ArgException& e ) 91 | { cout << "ERROR: " << e.error() << " " << e.argId() << endl; } 92 | } 93 | 94 | 95 | 96 | -------------------------------------------------------------------------------- /examples/test30.cpp: -------------------------------------------------------------------------------- 1 | // Example based on question in https://sourceforge.net/p/tclap/support-requests/2/ 2 | // 3 | // Shows how to use a pair as a "custom type". Note that the argument 4 | // flag must be specified, like -p "1 2.3" (with quotes). 5 | 6 | #include "tclap/CmdLine.h" 7 | #include 8 | #include 9 | 10 | using namespace TCLAP; 11 | 12 | // We need to tell TCLAP how to parse our pair, we assume it will be 13 | // given as two arguments separated by whitespace. 14 | std::istream &operator>>(std::istream &is, std::pair &p) { 15 | return is >> p.first >> p.second; 16 | } 17 | 18 | // Make it easy to print values of our type. 19 | std::ostream &operator<<(std::ostream &os, const std::pair &p) { 20 | return os << p.first << ' ' << p.second; 21 | } 22 | 23 | // Our pair can now be used as any other type. 24 | int main(int argc, char **argv) { 25 | CmdLine cmd("test pair argument"); 26 | ValueArg > parg("p", "pair", "int,double pair", 27 | true, 28 | std::make_pair(0, 0.0), 29 | "int,double", 30 | cmd); 31 | cmd.parse(argc, argv); 32 | std::cout << parg.getValue() << std::endl; 33 | } 34 | -------------------------------------------------------------------------------- /examples/test4.cpp: -------------------------------------------------------------------------------- 1 | // -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*- 2 | 3 | 4 | 5 | #include "tclap/CmdLine.h" 6 | #include "tclap/DocBookOutput.h" 7 | #include "tclap/ZshCompletionOutput.h" 8 | #include 9 | #include 10 | 11 | using namespace TCLAP; 12 | using namespace std; 13 | 14 | 15 | // This exemplifies how the output class can be overridden to provide 16 | // user defined output. 17 | class MyOutput : public StdOutput 18 | { 19 | public: 20 | 21 | virtual void failure(CmdLineInterface& c, ArgException& e) 22 | { 23 | static_cast(c); // Ignore input, don't warn 24 | cerr << "my failure message: " << endl 25 | << e.what() << endl; 26 | exit(1); 27 | } 28 | 29 | virtual void usage(CmdLineInterface& c) 30 | { 31 | cout << "my usage message:" << endl; 32 | list args = c.getArgList(); 33 | for (ArgListIterator it = args.begin(); it != args.end(); it++) 34 | cout << (*it)->longID() 35 | << " (" << (*it)->getDescription() << ")" << endl; 36 | } 37 | 38 | virtual void version(CmdLineInterface& c) 39 | { 40 | static_cast(c); // Ignore input, don't warn 41 | cout << "my version message: 0.1" << endl; 42 | } 43 | }; 44 | 45 | 46 | bool _boolTestB; 47 | bool _boolTestA; 48 | string _stringTest; 49 | 50 | void parseOptions(int argc, char** argv); 51 | 52 | int main(int argc, char** argv) 53 | { 54 | 55 | parseOptions(argc,argv); 56 | 57 | cout << "for string we got : " << _stringTest<< endl 58 | << "for bool B we got : " << _boolTestB << endl 59 | << "for bool A we got : " << _boolTestA << endl; 60 | 61 | } 62 | 63 | 64 | void parseOptions(int argc, char** argv) 65 | { 66 | try { 67 | 68 | CmdLine cmd("this is a message", ' ', "0.99" ); 69 | 70 | // set the output 71 | MyOutput my; 72 | //ZshCompletionOutput my; 73 | //DocBookOutput my; 74 | cmd.setOutput(&my); 75 | 76 | // 77 | // Define arguments 78 | // 79 | 80 | SwitchArg btest("B","sB", "exist Test B", false); 81 | SwitchArg atest("A","sA", "exist Test A", false); 82 | 83 | ValueArg stest("s", "Bs", "string test", true, "homer", 84 | "string"); 85 | cmd.add( stest ); 86 | cmd.add( btest ); 87 | cmd.add( atest ); 88 | 89 | // 90 | // Parse the command line. 91 | // 92 | cmd.parse(argc,argv); 93 | 94 | 95 | // 96 | // Set variables 97 | // 98 | _stringTest = stest.getValue(); 99 | _boolTestB = btest.getValue(); 100 | _boolTestA = atest.getValue(); 101 | 102 | 103 | } catch ( ArgException& e ) 104 | { cout << "ERROR: " << e.error() << " " << e.argId() << endl; } 105 | } 106 | 107 | 108 | 109 | -------------------------------------------------------------------------------- /examples/test5.cpp: -------------------------------------------------------------------------------- 1 | // -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*- 2 | 3 | 4 | 5 | #include "tclap/CmdLine.h" 6 | #include 7 | #include 8 | 9 | using namespace TCLAP; 10 | using namespace std; 11 | 12 | string _orTest; 13 | string _orTest2; 14 | string _testc; 15 | bool _testd; 16 | 17 | void parseOptions(int argc, char** argv); 18 | 19 | int main(int argc, char** argv) 20 | { 21 | 22 | parseOptions(argc,argv); 23 | 24 | cout << "for A OR B we got : " << _orTest<< endl 25 | << "for string C we got : " << _testc << endl 26 | << "for string D we got : " << _testd << endl 27 | << "for E or F or G we got: " << _orTest2 << endl; 28 | 29 | } 30 | 31 | 32 | void parseOptions(int argc, char** argv) 33 | { 34 | try { 35 | 36 | CmdLine cmd("this is a message", ' ', "0.99" ); 37 | 38 | // 39 | // Define arguments 40 | // 41 | 42 | ValueArg atest("a", "aaa", "or test a", true, "homer", "string"); 43 | ValueArg btest("b", "bbb", "or test b", true, "homer", "string"); 44 | cmd.xorAdd( atest, btest ); 45 | 46 | ValueArg ctest("c", "ccc", "c test", true, "homer", "string"); 47 | cmd.add( ctest ); 48 | 49 | SwitchArg dtest("", "ddd", "d test", false); 50 | cmd.add( dtest ); 51 | 52 | ValueArg etest("", "eee", "e test", false, "homer", "string"); 53 | ValueArg ftest("", "fff", "f test", false, "homer", "string"); 54 | ValueArg gtest("g", "ggg", "g test", false, "homer", "string"); 55 | vector xorlist; 56 | xorlist.push_back(&etest); 57 | xorlist.push_back(&ftest); 58 | xorlist.push_back(>est); 59 | cmd.xorAdd( xorlist ); 60 | 61 | MultiArg itest("i", "iii", "or test i", true, "string"); 62 | MultiArg jtest("j", "jjj", "or test j", true, "string"); 63 | cmd.xorAdd( itest, jtest ); 64 | 65 | // 66 | // Parse the command line. 67 | // 68 | cmd.parse(argc,argv); 69 | 70 | 71 | // 72 | // Set variables 73 | // 74 | 75 | if ( atest.isSet() ) 76 | _orTest = atest.getValue(); 77 | else if ( btest.isSet() ) 78 | _orTest = btest.getValue(); 79 | else 80 | // Should never get here because TCLAP will note that one of the 81 | // required args above has not been set. 82 | throw("very bad things..."); 83 | 84 | _testc = ctest.getValue(); 85 | _testd = dtest.getValue(); 86 | 87 | if ( etest.isSet() ) 88 | _orTest2 = etest.getValue(); 89 | else if ( ftest.isSet() ) 90 | _orTest2 = ftest.getValue(); 91 | else if ( gtest.isSet() ) 92 | _orTest2 = gtest.getValue(); 93 | else 94 | throw("still bad"); 95 | 96 | if ( jtest.isSet() ) 97 | { 98 | cout << "for J:" << endl; 99 | vector v = jtest.getValue(); 100 | for ( int z = 0; static_cast(z) < v.size(); z++ ) 101 | cout << " " << z << " " << v[z] << endl; 102 | } 103 | else if ( itest.isSet() ) 104 | { 105 | cout << "for I:" << endl; 106 | vector v = itest.getValue(); 107 | for ( int z = 0; static_cast(z) < v.size(); z++ ) 108 | cout << " " << z << " " << v[z] << endl; 109 | } 110 | else 111 | throw("yup, still bad"); 112 | 113 | 114 | 115 | } catch ( ArgException& e ) 116 | { cout << "ERROR: " << e.error() << " " << e.argId() << endl; } 117 | } 118 | 119 | 120 | 121 | -------------------------------------------------------------------------------- /examples/test6.cpp: -------------------------------------------------------------------------------- 1 | // -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*- 2 | 3 | #include 4 | #include "tclap/CmdLine.h" 5 | 6 | using namespace TCLAP; 7 | using namespace std; 8 | 9 | int main(int argc, char** argv) 10 | { 11 | // Wrap everything in a try block. Do this every time, 12 | // because exceptions will be thrown for problems. 13 | try { 14 | 15 | // Define the command line object. 16 | CmdLine cmd("Command description message", ' ', "0.9"); 17 | 18 | vector allowed; 19 | allowed.push_back("homer"); 20 | allowed.push_back("marge"); 21 | allowed.push_back("bart"); 22 | allowed.push_back("lisa"); 23 | allowed.push_back("maggie"); 24 | ValuesConstraint allowedVals( allowed ); 25 | 26 | ValueArg nameArg("n","name","Name to print",true,"homer", 27 | &allowedVals); 28 | cmd.add( nameArg ); 29 | 30 | vector iallowed; 31 | iallowed.push_back(1); 32 | iallowed.push_back(2); 33 | iallowed.push_back(3); 34 | ValuesConstraint iallowedVals( iallowed ); 35 | 36 | UnlabeledValueArg intArg("times","Number of times to print",true,1, 37 | &iallowedVals,false); 38 | cmd.add( intArg ); 39 | 40 | // Parse the args. 41 | cmd.parse( argc, argv ); 42 | 43 | // Get the value parsed by each arg. 44 | int num = intArg.getValue(); 45 | string name = nameArg.getValue(); 46 | 47 | for ( int i = 0; i < num; i++ ) 48 | cout << "My name is " << name << endl; 49 | 50 | } catch ( ArgException& e) // catch any exceptions 51 | { cerr << "error: " << e.error() << " for arg " << e.argId() << endl; } 52 | } 53 | 54 | -------------------------------------------------------------------------------- /examples/test7.cpp: -------------------------------------------------------------------------------- 1 | // -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*- 2 | 3 | #include 4 | #include "tclap/CmdLine.h" 5 | 6 | using namespace TCLAP; 7 | using namespace std; 8 | 9 | int main(int argc, char **argv) 10 | { 11 | // Wrap everything in a try block. Do this every time, 12 | // because exceptions will be thrown for problems. 13 | try { 14 | 15 | // Define the command line object. 16 | CmdLine cmd("Command description message. This is a long multi-line message meant to test line wrapping. This is more text that doesn't really do anything besides take up lots of space that otherwise might be used for something real. That should be enough, don't you think?", ' ', "0.9"); 17 | 18 | vector allowed; 19 | allowed.push_back("homer"); 20 | allowed.push_back("marge"); 21 | allowed.push_back("bart"); 22 | allowed.push_back("lisa"); 23 | allowed.push_back("maggie"); 24 | ValuesConstraint vallowed( allowed ); 25 | 26 | MultiArg nameArg("n","name","Name to print. This is a long, nonsensical message to test line wrapping. Hopefully it works.",true,&vallowed); 27 | cmd.add( nameArg ); 28 | 29 | vector iallowed; 30 | iallowed.push_back(1); 31 | iallowed.push_back(2); 32 | iallowed.push_back(3); 33 | ValuesConstraint iiallowed( iallowed ); 34 | 35 | UnlabeledMultiArg intArg("times","Number of times to print",false, 36 | &iiallowed); 37 | cmd.add( intArg ); 38 | 39 | // Ignore the names and comments! These args mean nothing (to this 40 | // program) and are here solely to take up space. 41 | ValueArg gapCreate("f","gapCreate", "The cost of creating a gap", 42 | false, -10, "negative int"); 43 | cmd.add( gapCreate ); 44 | 45 | ValueArg gapExtend("g","gap-Extend", 46 | "The cost for each extension of a gap", false, -2, "negative int"); 47 | cmd.add( gapExtend ); 48 | 49 | SwitchArg dna("d","isDna","The input sequences are DNA", false); 50 | cmd.add( dna ); 51 | 52 | ValueArg scoringMatrixName("s","scoring--Matrix", 53 | "Scoring Matrix name", false,"BLOSUM50","name string"); 54 | cmd.add( scoringMatrixName ); 55 | 56 | ValueArg seq1Filename ("x","filename1", 57 | "Sequence 1 filename (FASTA format)", false,"","filename"); 58 | cmd.add( seq1Filename ); 59 | 60 | ValueArg seq2Filename ("z","filename2", 61 | "Sequence 2 filename (FASTA format)", false,"","filename"); 62 | cmd.add( seq2Filename ); 63 | 64 | ValueArg lowerBound("b","lowerBound", "lower percentage bound", 65 | false,1.0,"float lte 1"); 66 | cmd.add( lowerBound ); 67 | 68 | ValueArg upperBound("u","upperBound", "upper percentage bound", 69 | false,1.0,"float lte 1"); 70 | cmd.add( upperBound ); 71 | 72 | ValueArg limit("l","limit","Max number of alignments allowed", 73 | false, 1000,"int"); 74 | cmd.add( limit ); 75 | 76 | argv[0] = const_cast("ThisIsAVeryLongProgramNameDesignedToTestSpacePrintWhichUsedToHaveProblemsWithLongProgramNamesIThinkItIsNowLongEnough"); 77 | 78 | // Parse the args. 79 | cmd.parse( argc, argv ); 80 | 81 | // Get the value parsed by each arg. 82 | vector num = intArg.getValue(); 83 | 84 | for ( unsigned int i = 0; i < num.size(); i++ ) 85 | cout << "Got num " << num[i] << endl; 86 | 87 | vector name = nameArg.getValue(); 88 | 89 | for ( unsigned int i = 0; i < name.size(); i++ ) 90 | cout << "Got name " << name[i] << endl; 91 | 92 | 93 | } catch (ArgException& e) // catch any exceptions 94 | { cerr << "error: " << e.error() << " for arg " << e.argId() << endl; } 95 | } 96 | 97 | -------------------------------------------------------------------------------- /examples/test8.cpp: -------------------------------------------------------------------------------- 1 | // -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*- 2 | 3 | 4 | 5 | #include "tclap/CmdLine.h" 6 | #include 7 | #include 8 | 9 | using namespace TCLAP; 10 | using namespace std; 11 | 12 | bool _boolTestB; 13 | string _stringTest; 14 | string _utest; 15 | string _ztest; 16 | 17 | void parseOptions(int argc, char** argv); 18 | 19 | int main(int argc, char** argv) 20 | { 21 | 22 | parseOptions(argc,argv); 23 | 24 | cout << "for string we got : " << _stringTest<< endl 25 | << "for ulabeled one we got : " << _utest << endl 26 | << "for ulabeled two we got : " << _ztest << endl 27 | << "for bool B we got : " << _boolTestB << endl; 28 | 29 | } 30 | 31 | 32 | void parseOptions(int argc, char** argv) 33 | { 34 | try { 35 | 36 | CmdLine cmd("this is a message", '=', "0.99" ); 37 | 38 | // 39 | // Define arguments 40 | // 41 | 42 | SwitchArg btest("B","existTestB", "exist Test B", cmd, false); 43 | 44 | ValueArg stest("s", "stringTest", "string test", true, "homer", 45 | "string", cmd ); 46 | 47 | UnlabeledValueArg utest("unTest1","unlabeled test one", true, 48 | "default","string", cmd ); 49 | 50 | UnlabeledValueArg ztest("unTest2","unlabeled test two", true, 51 | "default","string", cmd ); 52 | 53 | MultiArg itest("i", "intTest", "multi int test", false,"int", cmd ); 54 | 55 | MultiArg ftest("f", "floatTest", "multi float test", false,"float", 56 | cmd ); 57 | 58 | UnlabeledMultiArg mtest("fileName","file names", false, 59 | "fileNameString", cmd); 60 | // 61 | // Parse the command line. 62 | // 63 | cmd.parse(argc,argv); 64 | 65 | 66 | // 67 | // Set variables 68 | // 69 | _stringTest = stest.getValue(); 70 | _boolTestB = btest.getValue(); 71 | _utest = utest.getValue(); 72 | _ztest = ztest.getValue(); 73 | 74 | vector vi = itest.getValue(); 75 | for ( int i = 0; static_cast(i) < vi.size(); i++ ) 76 | cout << "[-i] " << i << " " << vi[i] << endl; 77 | 78 | vector vf = ftest.getValue(); 79 | for ( int i = 0; static_cast(i) < vf.size(); i++ ) 80 | cout << "[-f] " << i << " " << vf[i] << endl; 81 | 82 | vector v = mtest.getValue(); 83 | for ( int i = 0; static_cast(i) < v.size(); i++ ) 84 | cout << "[ ] " << i << " " << v[i] << endl; 85 | 86 | } catch ( ArgException& e ) 87 | { cout << "ERROR: " << e.error() << " " << e.argId() << endl; } 88 | } 89 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /examples/test9.cpp: -------------------------------------------------------------------------------- 1 | // -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*- 2 | 3 | #include 4 | #include 5 | #include 6 | #include "tclap/CmdLine.h" 7 | 8 | using namespace TCLAP; 9 | using namespace std; 10 | 11 | int main(int argc, char** argv) 12 | { 13 | try { 14 | 15 | CmdLine cmd("Command description message", ' ', "0.9",false); 16 | 17 | SwitchArg reverseSwitch("r","reverse","REVERSE instead of FORWARDS", false); 18 | cmd.add( reverseSwitch ); 19 | 20 | MultiSwitchArg verbose("V","verbose","Level of verbosity"); 21 | cmd.add( verbose ); 22 | 23 | MultiSwitchArg noise("N","noise","Level of noise",5); 24 | cmd.add( noise ); 25 | 26 | UnlabeledValueArg word("word","a random word", false, "string", 27 | "won't see this",false); 28 | cmd.add( word ); 29 | 30 | // Uncommenting the next arg will (correctly) cause an exception 31 | // to be thrown. 32 | 33 | // UnlabeledMultiArg badword("badword","a bad word", false,"string"); 34 | // 35 | // cmd.add( badword ); 36 | 37 | cmd.parse( argc, argv ); 38 | 39 | bool reverseName = reverseSwitch.getValue(); 40 | 41 | if ( reverseName ) 42 | cout << "REVERSE" << endl; 43 | else 44 | cout << "FORWARD" << endl; 45 | 46 | if ( verbose.isSet() ) 47 | cout << "Verbose level: " << verbose.getValue() << endl; 48 | 49 | if ( noise.isSet() ) 50 | cout << "Noise level: " << noise.getValue() << endl; 51 | 52 | if ( word.isSet() ) 53 | cout << "Word: " << word.getValue() << endl; 54 | 55 | } catch (ArgException &e) // catch any exceptions 56 | { cerr << "error: " << e.error() << " for arg " << e.argId() << endl; } 57 | } 58 | 59 | -------------------------------------------------------------------------------- /include/Makefile.am: -------------------------------------------------------------------------------- 1 | SUBDIRS = tclap 2 | -------------------------------------------------------------------------------- /include/tclap/ArgTraits.h: -------------------------------------------------------------------------------- 1 | // -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*- 2 | 3 | /****************************************************************************** 4 | * 5 | * file: ArgTraits.h 6 | * 7 | * Copyright (c) 2007, Daniel Aarno, Michael E. Smoot . 8 | * Copyright (c) 2017 Google LLC 9 | * All rights reserved. 10 | * 11 | * See the file COPYING in the top directory of this distribution for 12 | * more information. 13 | * 14 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 | * DEALINGS IN THE SOFTWARE. 21 | * 22 | *****************************************************************************/ 23 | 24 | // This is an internal tclap file, you should probably not have to 25 | // include this directly 26 | 27 | #ifndef TCLAP_ARGTRAITS_H 28 | #define TCLAP_ARGTRAITS_H 29 | 30 | namespace TCLAP { 31 | 32 | // We use two empty structs to get compile type specialization 33 | // function to work 34 | 35 | /** 36 | * A value like argument value type is a value that can be set using 37 | * operator>>. This is the default value type. 38 | */ 39 | struct ValueLike { 40 | typedef ValueLike ValueCategory; 41 | virtual ~ValueLike() {} 42 | }; 43 | 44 | /** 45 | * A string like argument value type is a value that can be set using 46 | * operator=(string). Useful if the value type contains spaces which 47 | * will be broken up into individual tokens by operator>>. 48 | */ 49 | struct StringLike { 50 | virtual ~StringLike() {} 51 | }; 52 | 53 | /** 54 | * A class can inherit from this object to make it have string like 55 | * traits. This is a compile time thing and does not add any overhead 56 | * to the inherenting class. 57 | */ 58 | struct StringLikeTrait { 59 | typedef StringLike ValueCategory; 60 | virtual ~StringLikeTrait() {} 61 | }; 62 | 63 | /** 64 | * A class can inherit from this object to make it have value like 65 | * traits. This is a compile time thing and does not add any overhead 66 | * to the inherenting class. 67 | */ 68 | struct ValueLikeTrait { 69 | typedef ValueLike ValueCategory; 70 | virtual ~ValueLikeTrait() {} 71 | }; 72 | 73 | /** 74 | * Arg traits are used to get compile type specialization when parsing 75 | * argument values. Using an ArgTraits you can specify the way that 76 | * values gets assigned to any particular type during parsing. The two 77 | * supported types are StringLike and ValueLike. ValueLike is the 78 | * default and means that operator>> will be used to assign values to 79 | * the type. 80 | */ 81 | template 82 | class ArgTraits { 83 | // This is a bit silly, but what we want to do is: 84 | // 1) If there exists a specialization of ArgTraits for type X, 85 | // use it. 86 | // 87 | // 2) If no specialization exists but X has the typename 88 | // X::ValueCategory, use the specialization for X::ValueCategory. 89 | // 90 | // 3) If neither (1) nor (2) defines the trait, use the default 91 | // which is ValueLike. 92 | 93 | // This is the "how": 94 | // 95 | // test(0) (where 0 is the NULL ptr) will match 96 | // test(typename C::ValueCategory*) iff type T has the 97 | // corresponding typedef. If it does not test(...) will be 98 | // matched. This allows us to determine if T::ValueCategory 99 | // exists by checking the sizeof for the test function (return 100 | // value must have different sizeof). 101 | template static short test(typename C::ValueCategory*); 102 | template static long test(...); 103 | static const bool hasTrait = sizeof(test(0)) == sizeof(short); 104 | 105 | template 106 | struct DefaultArgTrait { 107 | typedef ValueLike ValueCategory; 108 | }; 109 | 110 | template 111 | struct DefaultArgTrait { 112 | typedef typename C::ValueCategory ValueCategory; 113 | }; 114 | 115 | public: 116 | typedef typename DefaultArgTrait::ValueCategory ValueCategory; 117 | }; 118 | 119 | } // namespace 120 | 121 | #endif 122 | 123 | -------------------------------------------------------------------------------- /include/tclap/CmdLineOutput.h: -------------------------------------------------------------------------------- 1 | // -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*- 2 | 3 | 4 | 5 | /****************************************************************************** 6 | * 7 | * file: CmdLineOutput.h 8 | * 9 | * Copyright (c) 2004, Michael E. Smoot 10 | * Copyright (c) 2017, Google LLC 11 | * All rights reserved. 12 | * 13 | * See the file COPYING in the top directory of this distribution for 14 | * more information. 15 | * 16 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS 17 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 19 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 22 | * DEALINGS IN THE SOFTWARE. 23 | * 24 | *****************************************************************************/ 25 | 26 | #ifndef TCLAP_CMDLINEOUTPUT_H 27 | #define TCLAP_CMDLINEOUTPUT_H 28 | 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | 36 | namespace TCLAP { 37 | 38 | class CmdLineInterface; 39 | class ArgException; 40 | 41 | /** 42 | * The interface that any output object must implement. 43 | */ 44 | class CmdLineOutput 45 | { 46 | 47 | public: 48 | 49 | /** 50 | * Virtual destructor. 51 | */ 52 | virtual ~CmdLineOutput() {} 53 | 54 | /** 55 | * Generates some sort of output for the USAGE. 56 | * \param c - The CmdLine object the output is generated for. 57 | */ 58 | virtual void usage(CmdLineInterface& c)=0; 59 | 60 | /** 61 | * Generates some sort of output for the version. 62 | * \param c - The CmdLine object the output is generated for. 63 | */ 64 | virtual void version(CmdLineInterface& c)=0; 65 | 66 | /** 67 | * Generates some sort of output for a failure. 68 | * \param c - The CmdLine object the output is generated for. 69 | * \param e - The ArgException that caused the failure. 70 | */ 71 | virtual void failure( CmdLineInterface& c, 72 | ArgException& e )=0; 73 | 74 | }; 75 | 76 | } //namespace TCLAP 77 | #endif 78 | -------------------------------------------------------------------------------- /include/tclap/Constraint.h: -------------------------------------------------------------------------------- 1 | // -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*- 2 | 3 | 4 | /****************************************************************************** 5 | * 6 | * file: Constraint.h 7 | * 8 | * Copyright (c) 2005, Michael E. Smoot 9 | * Copyright (c) 2017, Google LLC 10 | * All rights reserved. 11 | * 12 | * See the file COPYING in the top directory of this distribution for 13 | * more information. 14 | * 15 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS 16 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 | * DEALINGS IN THE SOFTWARE. 22 | * 23 | *****************************************************************************/ 24 | 25 | #ifndef TCLAP_CONSTRAINT_H 26 | #define TCLAP_CONSTRAINT_H 27 | 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | 36 | namespace TCLAP { 37 | 38 | /** 39 | * The interface that defines the interaction between the Arg and Constraint. 40 | */ 41 | template 42 | class Constraint 43 | { 44 | 45 | public: 46 | /** 47 | * Returns a description of the Constraint. 48 | */ 49 | virtual std::string description() const =0; 50 | 51 | /** 52 | * Returns the short ID for the Constraint. 53 | */ 54 | virtual std::string shortID() const =0; 55 | 56 | /** 57 | * The method used to verify that the value parsed from the command 58 | * line meets the constraint. 59 | * \param value - The value that will be checked. 60 | */ 61 | virtual bool check(const T& value) const =0; 62 | 63 | /** 64 | * Destructor. 65 | * Silences warnings about Constraint being a base class with virtual 66 | * functions but without a virtual destructor. 67 | */ 68 | virtual ~Constraint() { ; } 69 | 70 | static std::string shortID(Constraint *constraint) { 71 | if (!constraint) 72 | throw std::logic_error("Cannot create a ValueArg with a NULL constraint"); 73 | return constraint->shortID(); 74 | } 75 | }; 76 | 77 | } //namespace TCLAP 78 | #endif 79 | -------------------------------------------------------------------------------- /include/tclap/HelpVisitor.h: -------------------------------------------------------------------------------- 1 | // -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*- 2 | 3 | 4 | /****************************************************************************** 5 | * 6 | * file: HelpVisitor.h 7 | * 8 | * Copyright (c) 2003, Michael E. Smoot . 9 | * All rights reserved. 10 | * 11 | * See the file COPYING in the top directory of this distribution for 12 | * more information. 13 | * 14 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 | * DEALINGS IN THE SOFTWARE. 21 | * 22 | *****************************************************************************/ 23 | 24 | #ifndef TCLAP_HELP_VISITOR_H 25 | #define TCLAP_HELP_VISITOR_H 26 | 27 | #include 28 | #include 29 | #include 30 | 31 | namespace TCLAP { 32 | 33 | /** 34 | * A Visitor object that calls the usage method of the given CmdLineOutput 35 | * object for the specified CmdLine object. 36 | */ 37 | class HelpVisitor: public Visitor 38 | { 39 | private: 40 | /** 41 | * Prevent accidental copying. 42 | */ 43 | HelpVisitor(const HelpVisitor& rhs); 44 | HelpVisitor& operator=(const HelpVisitor& rhs); 45 | 46 | protected: 47 | 48 | /** 49 | * The CmdLine the output will be generated for. 50 | */ 51 | CmdLineInterface* _cmd; 52 | 53 | /** 54 | * The output object. 55 | */ 56 | CmdLineOutput** _out; 57 | 58 | public: 59 | 60 | /** 61 | * Constructor. 62 | * \param cmd - The CmdLine the output will be generated for. 63 | * \param out - The type of output. 64 | */ 65 | HelpVisitor(CmdLineInterface* cmd, CmdLineOutput** out) 66 | : Visitor(), _cmd( cmd ), _out( out ) { } 67 | 68 | /** 69 | * Calls the usage method of the CmdLineOutput for the 70 | * specified CmdLine. 71 | */ 72 | void visit() { (*_out)->usage(*_cmd); throw ExitException(0); } 73 | 74 | }; 75 | 76 | } 77 | 78 | #endif 79 | -------------------------------------------------------------------------------- /include/tclap/IgnoreRestVisitor.h: -------------------------------------------------------------------------------- 1 | // -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*- 2 | 3 | 4 | /****************************************************************************** 5 | * 6 | * file: IgnoreRestVisitor.h 7 | * 8 | * Copyright (c) 2003, Michael E. Smoot . 9 | * All rights reserved. 10 | * 11 | * See the file COPYING in the top directory of this distribution for 12 | * more information. 13 | * 14 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 | * DEALINGS IN THE SOFTWARE. 21 | * 22 | *****************************************************************************/ 23 | 24 | 25 | #ifndef TCLAP_IGNORE_REST_VISITOR_H 26 | #define TCLAP_IGNORE_REST_VISITOR_H 27 | 28 | #include 29 | #include 30 | 31 | namespace TCLAP { 32 | 33 | /** 34 | * A Visitor that tells the CmdLine to begin ignoring arguments after 35 | * this one is parsed. 36 | */ 37 | class IgnoreRestVisitor: public Visitor 38 | { 39 | public: 40 | 41 | /** 42 | * Constructor. 43 | */ 44 | IgnoreRestVisitor() : Visitor() {} 45 | 46 | /** 47 | * Sets Arg::_ignoreRest. 48 | */ 49 | void visit() { Arg::beginIgnoring(); } 50 | }; 51 | 52 | } 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /include/tclap/Makefile.am: -------------------------------------------------------------------------------- 1 | 2 | libtclapincludedir = $(includedir)/tclap 3 | 4 | libtclapinclude_HEADERS = \ 5 | Arg.h \ 6 | ArgException.h \ 7 | ArgTraits.h \ 8 | CmdLine.h \ 9 | CmdLineInterface.h \ 10 | CmdLineOutput.h \ 11 | Constraint.h \ 12 | DocBookOutput.h \ 13 | HelpVisitor.h \ 14 | IgnoreRestVisitor.h \ 15 | MultiArg.h \ 16 | MultiSwitchArg.h \ 17 | OptionalUnlabeledTracker.h \ 18 | StandardTraits.h \ 19 | StdOutput.h \ 20 | SwitchArg.h \ 21 | UnlabeledMultiArg.h \ 22 | UnlabeledValueArg.h \ 23 | ValueArg.h \ 24 | ValuesConstraint.h \ 25 | VersionVisitor.h \ 26 | Visitor.h \ 27 | XorHandler.h \ 28 | ZshCompletionOutput.h \ 29 | sstream.h 30 | -------------------------------------------------------------------------------- /include/tclap/OptionalUnlabeledTracker.h: -------------------------------------------------------------------------------- 1 | // -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*- 2 | 3 | 4 | 5 | /****************************************************************************** 6 | * 7 | * file: OptionalUnlabeledTracker.h 8 | * 9 | * Copyright (c) 2005, Michael E. Smoot . 10 | * All rights reserved. 11 | * 12 | * See the file COPYING in the top directory of this distribution for 13 | * more information. 14 | * 15 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS 16 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 | * DEALINGS IN THE SOFTWARE. 22 | * 23 | *****************************************************************************/ 24 | 25 | 26 | #ifndef TCLAP_OPTIONAL_UNLABELED_TRACKER_H 27 | #define TCLAP_OPTIONAL_UNLABELED_TRACKER_H 28 | 29 | #include 30 | 31 | namespace TCLAP { 32 | 33 | class OptionalUnlabeledTracker 34 | { 35 | 36 | public: 37 | 38 | static void check( bool req, const std::string& argName ); 39 | 40 | static void gotOptional() { alreadyOptionalRef() = true; } 41 | 42 | static bool& alreadyOptional() { return alreadyOptionalRef(); } 43 | 44 | private: 45 | 46 | static bool& alreadyOptionalRef() { static bool ct = false; return ct; } 47 | }; 48 | 49 | 50 | inline void OptionalUnlabeledTracker::check( bool req, const std::string& argName ) 51 | { 52 | if ( OptionalUnlabeledTracker::alreadyOptional() ) 53 | throw( SpecificationException( 54 | "You can't specify ANY Unlabeled Arg following an optional Unlabeled Arg", 55 | argName ) ); 56 | 57 | if ( !req ) 58 | OptionalUnlabeledTracker::gotOptional(); 59 | } 60 | 61 | 62 | } // namespace TCLAP 63 | 64 | #endif 65 | -------------------------------------------------------------------------------- /include/tclap/StandardTraits.h: -------------------------------------------------------------------------------- 1 | // -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*- 2 | 3 | /****************************************************************************** 4 | * 5 | * file: StandardTraits.h 6 | * 7 | * Copyright (c) 2007, Daniel Aarno, Michael E. Smoot . 8 | * Copyright (c) 2017, Google LLC 9 | * All rights reserved. 10 | * 11 | * See the file COPYING in the top directory of this distribution for 12 | * more information. 13 | * 14 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 | * DEALINGS IN THE SOFTWARE. 21 | * 22 | *****************************************************************************/ 23 | 24 | // This is an internal tclap file, you should probably not have to 25 | // include this directly 26 | 27 | #ifndef TCLAP_STANDARD_TRAITS_H 28 | #define TCLAP_STANDARD_TRAITS_H 29 | 30 | #ifdef HAVE_CONFIG_H 31 | #include // To check for long long 32 | #endif 33 | 34 | // If Microsoft has already typedef'd wchar_t as an unsigned 35 | // short, then compiles will break because it's as if we're 36 | // creating ArgTraits twice for unsigned short. Thus... 37 | #ifdef _MSC_VER 38 | #ifndef _NATIVE_WCHAR_T_DEFINED 39 | #define TCLAP_DONT_DECLARE_WCHAR_T_ARGTRAITS 40 | #endif 41 | #endif 42 | 43 | namespace TCLAP { 44 | 45 | // Integer types (signed, unsigned and bool) and floating point types all 46 | // have value-like semantics. 47 | 48 | // Strings have string like argument traits. 49 | template<> 50 | struct ArgTraits { 51 | typedef StringLike ValueCategory; 52 | }; 53 | 54 | template 55 | void SetString(T &dst, const std::string &src) 56 | { 57 | dst = src; 58 | } 59 | 60 | } // namespace 61 | 62 | #endif 63 | 64 | -------------------------------------------------------------------------------- /include/tclap/ValuesConstraint.h: -------------------------------------------------------------------------------- 1 | // -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*- 2 | 3 | 4 | 5 | /****************************************************************************** 6 | * 7 | * file: ValuesConstraint.h 8 | * 9 | * Copyright (c) 2005, Michael E. Smoot 10 | * Copyright (c) 2017, Google LLC 11 | * All rights reserved. 12 | * 13 | * See the file COPYING in the top directory of this distribution for 14 | * more information. 15 | * 16 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS 17 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 19 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 22 | * DEALINGS IN THE SOFTWARE. 23 | * 24 | *****************************************************************************/ 25 | 26 | #ifndef TCLAP_VALUESCONSTRAINT_H 27 | #define TCLAP_VALUESCONSTRAINT_H 28 | 29 | #ifdef HAVE_CONFIG_H 30 | #include 31 | #endif 32 | 33 | #include 34 | #include 35 | #include 36 | #include 37 | 38 | namespace TCLAP { 39 | 40 | /** 41 | * A Constraint that constrains the Arg to only those values specified 42 | * in the constraint. 43 | */ 44 | template 45 | class ValuesConstraint : public Constraint 46 | { 47 | 48 | public: 49 | 50 | /** 51 | * Constructor. 52 | * \param allowed - vector of allowed values. 53 | */ 54 | ValuesConstraint(std::vectorconst& allowed); 55 | 56 | /** 57 | * Virtual destructor. 58 | */ 59 | virtual ~ValuesConstraint() {} 60 | 61 | /** 62 | * Returns a description of the Constraint. 63 | */ 64 | virtual std::string description() const; 65 | 66 | /** 67 | * Returns the short ID for the Constraint. 68 | */ 69 | virtual std::string shortID() const; 70 | 71 | /** 72 | * The method used to verify that the value parsed from the command 73 | * line meets the constraint. 74 | * \param value - The value that will be checked. 75 | */ 76 | virtual bool check(const T& value) const; 77 | 78 | protected: 79 | 80 | /** 81 | * The list of valid values. 82 | */ 83 | std::vector _allowed; 84 | 85 | /** 86 | * The string used to describe the allowed values of this constraint. 87 | */ 88 | std::string _typeDesc; 89 | 90 | }; 91 | 92 | template 93 | ValuesConstraint::ValuesConstraint(std::vector const& allowed) 94 | : _allowed(allowed), 95 | _typeDesc("") 96 | { 97 | for ( unsigned int i = 0; i < _allowed.size(); i++ ) 98 | { 99 | std::ostringstream os; 100 | os << _allowed[i]; 101 | 102 | std::string temp( os.str() ); 103 | 104 | if ( i > 0 ) 105 | _typeDesc += "|"; 106 | _typeDesc += temp; 107 | } 108 | } 109 | 110 | template 111 | bool ValuesConstraint::check( const T& val ) const 112 | { 113 | if ( std::find(_allowed.begin(),_allowed.end(),val) == _allowed.end() ) 114 | return false; 115 | else 116 | return true; 117 | } 118 | 119 | template 120 | std::string ValuesConstraint::shortID() const 121 | { 122 | return _typeDesc; 123 | } 124 | 125 | template 126 | std::string ValuesConstraint::description() const 127 | { 128 | return _typeDesc; 129 | } 130 | 131 | 132 | } //namespace TCLAP 133 | #endif 134 | 135 | -------------------------------------------------------------------------------- /include/tclap/VersionVisitor.h: -------------------------------------------------------------------------------- 1 | // -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*- 2 | 3 | /****************************************************************************** 4 | * 5 | * file: VersionVisitor.h 6 | * 7 | * Copyright (c) 2003, Michael E. Smoot . 8 | * All rights reserved. 9 | * 10 | * See the file COPYING in the top directory of this distribution for 11 | * more information. 12 | * 13 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS 14 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 16 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19 | * DEALINGS IN THE SOFTWARE. 20 | * 21 | *****************************************************************************/ 22 | 23 | 24 | #ifndef TCLAP_VERSION_VISITOR_H 25 | #define TCLAP_VERSION_VISITOR_H 26 | 27 | #include 28 | #include 29 | #include 30 | 31 | namespace TCLAP { 32 | 33 | /** 34 | * A Visitor that will call the version method of the given CmdLineOutput 35 | * for the specified CmdLine object and then exit. 36 | */ 37 | class VersionVisitor: public Visitor 38 | { 39 | private: 40 | /** 41 | * Prevent accidental copying 42 | */ 43 | VersionVisitor(const VersionVisitor& rhs); 44 | VersionVisitor& operator=(const VersionVisitor& rhs); 45 | 46 | protected: 47 | 48 | /** 49 | * The CmdLine of interest. 50 | */ 51 | CmdLineInterface* _cmd; 52 | 53 | /** 54 | * The output object. 55 | */ 56 | CmdLineOutput** _out; 57 | 58 | public: 59 | 60 | /** 61 | * Constructor. 62 | * \param cmd - The CmdLine the output is generated for. 63 | * \param out - The type of output. 64 | */ 65 | VersionVisitor( CmdLineInterface* cmd, CmdLineOutput** out ) 66 | : Visitor(), _cmd( cmd ), _out( out ) { } 67 | 68 | /** 69 | * Calls the version method of the output object using the 70 | * specified CmdLine. 71 | */ 72 | void visit() { 73 | (*_out)->version(*_cmd); 74 | throw ExitException(0); 75 | } 76 | 77 | }; 78 | 79 | } 80 | 81 | #endif 82 | -------------------------------------------------------------------------------- /include/tclap/Visitor.h: -------------------------------------------------------------------------------- 1 | // -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*- 2 | 3 | 4 | /****************************************************************************** 5 | * 6 | * file: Visitor.h 7 | * 8 | * Copyright (c) 2003, Michael E. Smoot . 9 | * Copyright (c) 2017, Google LLC 10 | * All rights reserved. 11 | * 12 | * See the file COPYING in the top directory of this distribution for 13 | * more information. 14 | * 15 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS 16 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 | * DEALINGS IN THE SOFTWARE. 22 | * 23 | *****************************************************************************/ 24 | 25 | 26 | #ifndef TCLAP_VISITOR_H 27 | #define TCLAP_VISITOR_H 28 | 29 | namespace TCLAP { 30 | 31 | /** 32 | * A base class that defines the interface for visitors. 33 | */ 34 | class Visitor 35 | { 36 | public: 37 | 38 | /** 39 | * Constructor. Does nothing. 40 | */ 41 | Visitor() { } 42 | 43 | /** 44 | * Destructor. Does nothing. 45 | */ 46 | virtual ~Visitor() { } 47 | 48 | /** 49 | * This method (to implemented by children) will be 50 | * called when the visitor is visited. 51 | */ 52 | virtual void visit() = 0; 53 | }; 54 | 55 | } 56 | 57 | #endif 58 | -------------------------------------------------------------------------------- /include/tclap/sstream.h: -------------------------------------------------------------------------------- 1 | // -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*- 2 | 3 | /****************************************************************************** 4 | * 5 | * file: sstream.h 6 | * 7 | * Copyright (c) 2003, Michael E. Smoot . 8 | * Copyright (c) 2004, Michael E. Smoot, Daniel Aarno . 9 | * Copyright (c) 2017 Google Inc. 10 | * All rights reserved. 11 | * 12 | * See the file COPYING in the top directory of this distribution for 13 | * more information. 14 | * 15 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS 16 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 | * DEALINGS IN THE SOFTWARE. 22 | * 23 | *****************************************************************************/ 24 | 25 | #ifndef TCLAP_SSTREAM_H 26 | #define TCLAP_SSTREAM_H 27 | 28 | #if !defined(HAVE_STRSTREAM) 29 | // Assume sstream is available if strstream is not specified 30 | // (https://sourceforge.net/p/tclap/bugs/23/) 31 | #define HAVE_SSTREAM 32 | #endif 33 | 34 | #if defined(HAVE_SSTREAM) 35 | #include 36 | namespace TCLAP { 37 | typedef std::istringstream istringstream; 38 | typedef std::ostringstream ostringstream; 39 | } 40 | #elif defined(HAVE_STRSTREAM) 41 | #include 42 | namespace TCLAP { 43 | typedef std::istrstream istringstream; 44 | typedef std::ostrstream ostringstream; 45 | } 46 | #else 47 | #error "Need a stringstream (sstream or strstream) to compile!" 48 | #endif 49 | 50 | #endif // TCLAP_SSTREAM_H 51 | -------------------------------------------------------------------------------- /msc/Makefile.am: -------------------------------------------------------------------------------- 1 | SUBDIRS = examples 2 | 3 | EXTRA_DIST = README\ 4 | tclap-beta.ncb\ 5 | tclap-beta.sln\ 6 | tclap-beta.suo\ 7 | tclap-beta.vcproj 8 | 9 | 10 | -------------------------------------------------------------------------------- /msc/README: -------------------------------------------------------------------------------- 1 | 2 | Disclaimer! 3 | =========== 4 | 5 | The various files included in the subdirectory for provided as a courtesy 6 | to Microsoft Visual Studio users. The files were contributed by a thoughtful 7 | user and were not created by the authors of this project. Moreover, the 8 | (current) authors have no way of maintaining, improving or even using the 9 | files. 10 | 11 | ** This means we can't answer any questions about the files! ** 12 | 13 | That said, we have several reports of people successfully using the TCLAP 14 | library on various Windows platforms. As long as you use a reasonably modern 15 | compiler (and Visual C++ apparently is), you shouldn't have any trouble. 16 | 17 | Good luck! 18 | -------------------------------------------------------------------------------- /msc/examples/Makefile.am: -------------------------------------------------------------------------------- 1 | 2 | EXTRA_DIST = test1.vcproj\ 3 | test2.vcproj\ 4 | test3.vcproj\ 5 | test4.vcproj\ 6 | test5.vcproj\ 7 | test6.vcproj\ 8 | test7.vcproj\ 9 | test8.vcproj 10 | 11 | -------------------------------------------------------------------------------- /msc/examples/test1.vcproj: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 11 | 12 | 13 | 19 | 31 | 33 | 42 | 44 | 46 | 48 | 50 | 52 | 54 | 56 | 58 | 60 | 62 | 63 | 69 | 78 | 80 | 90 | 92 | 94 | 96 | 98 | 100 | 102 | 104 | 106 | 108 | 110 | 111 | 112 | 113 | 114 | 115 | 119 | 121 | 122 | 123 | 127 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | -------------------------------------------------------------------------------- /msc/examples/test2.vcproj: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 11 | 12 | 13 | 19 | 31 | 33 | 42 | 44 | 46 | 48 | 50 | 52 | 54 | 56 | 58 | 60 | 62 | 63 | 69 | 78 | 80 | 90 | 92 | 94 | 96 | 98 | 100 | 102 | 104 | 106 | 108 | 110 | 111 | 112 | 113 | 114 | 115 | 119 | 121 | 122 | 123 | 127 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | -------------------------------------------------------------------------------- /msc/examples/test3.vcproj: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 11 | 12 | 13 | 19 | 31 | 33 | 42 | 44 | 46 | 48 | 50 | 52 | 54 | 56 | 58 | 60 | 62 | 63 | 69 | 78 | 80 | 90 | 92 | 94 | 96 | 98 | 100 | 102 | 104 | 106 | 108 | 110 | 111 | 112 | 113 | 114 | 115 | 119 | 121 | 122 | 123 | 127 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | -------------------------------------------------------------------------------- /msc/examples/test4.vcproj: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 11 | 12 | 13 | 19 | 31 | 33 | 42 | 44 | 46 | 48 | 50 | 52 | 54 | 56 | 58 | 60 | 62 | 63 | 69 | 78 | 80 | 90 | 92 | 94 | 96 | 98 | 100 | 102 | 104 | 106 | 108 | 110 | 111 | 112 | 113 | 114 | 115 | 119 | 121 | 122 | 123 | 127 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | -------------------------------------------------------------------------------- /msc/examples/test5.vcproj: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 11 | 12 | 13 | 19 | 31 | 33 | 42 | 44 | 46 | 48 | 50 | 52 | 54 | 56 | 58 | 60 | 62 | 63 | 69 | 78 | 80 | 90 | 92 | 94 | 96 | 98 | 100 | 102 | 104 | 106 | 108 | 110 | 111 | 112 | 113 | 114 | 115 | 119 | 121 | 122 | 123 | 127 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | -------------------------------------------------------------------------------- /msc/examples/test6.vcproj: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 11 | 12 | 13 | 19 | 31 | 33 | 42 | 44 | 46 | 48 | 50 | 52 | 54 | 56 | 58 | 60 | 62 | 63 | 69 | 78 | 80 | 90 | 92 | 94 | 96 | 98 | 100 | 102 | 104 | 106 | 108 | 110 | 111 | 112 | 113 | 114 | 115 | 119 | 121 | 122 | 123 | 127 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | -------------------------------------------------------------------------------- /msc/examples/test7.vcproj: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 11 | 12 | 13 | 19 | 31 | 33 | 42 | 44 | 46 | 48 | 50 | 52 | 54 | 56 | 58 | 60 | 62 | 63 | 69 | 78 | 80 | 90 | 92 | 94 | 96 | 98 | 100 | 102 | 104 | 106 | 108 | 110 | 111 | 112 | 113 | 114 | 115 | 119 | 121 | 122 | 123 | 127 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | -------------------------------------------------------------------------------- /msc/examples/test8.vcproj: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 11 | 12 | 13 | 19 | 31 | 33 | 42 | 44 | 46 | 48 | 50 | 52 | 54 | 56 | 58 | 60 | 62 | 63 | 69 | 78 | 80 | 90 | 92 | 94 | 96 | 98 | 100 | 102 | 104 | 106 | 108 | 110 | 111 | 112 | 113 | 114 | 115 | 119 | 121 | 122 | 123 | 127 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | -------------------------------------------------------------------------------- /msc/tclap-beta.ncb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mirror/tclap/8b35dd1c23922231ec2dcb95edea0285189de039/msc/tclap-beta.ncb -------------------------------------------------------------------------------- /msc/tclap-beta.suo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mirror/tclap/8b35dd1c23922231ec2dcb95edea0285189de039/msc/tclap-beta.suo -------------------------------------------------------------------------------- /msc/tclap-beta.vcproj: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 11 | 12 | 13 | 19 | 30 | 32 | 40 | 42 | 44 | 46 | 48 | 50 | 52 | 54 | 56 | 58 | 60 | 61 | 67 | 75 | 77 | 86 | 88 | 90 | 92 | 94 | 96 | 98 | 100 | 102 | 104 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | -------------------------------------------------------------------------------- /scripts/check_dead_headers.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # Copyright (c) 2018 Google LLC 4 | # All rights reserved. 5 | # 6 | # See the file COPYING in the top directory of this distribution for 7 | # more information. 8 | # 9 | # THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS 10 | # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 11 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 12 | # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 13 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 14 | # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 15 | # DEALINGS IN THE SOFTWARE. 16 | 17 | import glob 18 | import os 19 | import sys 20 | import re 21 | 22 | def get_files(path, pattern): 23 | return map(os.path.basename, 24 | glob.glob(os.path.join(path, pattern))) 25 | 26 | def get_includes(path): 27 | with file(os.path.join(path, 'Makefile.am')) as f: 28 | lines = [] 29 | 30 | for line in f: 31 | m = re.match(r'^(.+\.h)', line.strip()) 32 | if m: 33 | lines.append(m.group(1)) 34 | 35 | return lines 36 | 37 | def main(): 38 | headers = set(get_files('./include/tclap', '*.h')) 39 | includes = set(get_includes('./include/tclap')) 40 | diff = headers - includes 41 | if diff: 42 | print 'The following files are not in Makefile.am' 43 | print diff 44 | sys.exit(1) 45 | 46 | if __name__ == '__main__': 47 | main() 48 | -------------------------------------------------------------------------------- /scripts/check_tests_enabled.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # Copyright (c) 2017 Google Inc. 4 | # All rights reserved. 5 | # 6 | # See the file COPYING in the top directory of this distribution for 7 | # more information. 8 | # 9 | # THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS 10 | # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 11 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 12 | # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 13 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 14 | # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 15 | # DEALINGS IN THE SOFTWARE. 16 | 17 | import glob 18 | import os 19 | import sys 20 | import re 21 | 22 | ignored_files = frozenset(['testCheck.sh']) 23 | 24 | def get_test_files(path): 25 | return map(os.path.basename, 26 | glob.glob(os.path.join(path, 'test*.sh'))) 27 | 28 | def get_test_cases(path): 29 | with file(os.path.join(path, 'Makefile.am')) as f: 30 | lines = [] 31 | for line in f: 32 | m = re.match(r'.*(test\d+\.sh).*', line.strip()) 33 | if m: 34 | lines.append(m.group(1)) 35 | 36 | return lines 37 | 38 | def main(): 39 | test_files = set(get_test_files('./tests')) - ignored_files 40 | test_cases = set(get_test_cases('./tests')) 41 | diff = test_files - test_cases 42 | if diff: 43 | print 'The following files are not in Makefile.am' 44 | print diff 45 | sys.exit(1) 46 | 47 | if __name__ == '__main__': 48 | main() 49 | 50 | -------------------------------------------------------------------------------- /scripts/fix-test.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | 3 | # Copyright (c) 2018 Google LLC 4 | # All rights reserved. 5 | # 6 | # See the file COPYING in the top directory of this distribution for 7 | # more information. 8 | # 9 | # THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS 10 | # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 11 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 12 | # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 13 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 14 | # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 15 | # DEALINGS IN THE SOFTWARE. 16 | 17 | import sys 18 | import re 19 | 20 | def process_file(path): 21 | args = None 22 | out = None 23 | test = None 24 | 25 | lines = [] 26 | 27 | with open(path) as f: 28 | for line in f.readlines(): 29 | if line.startswith('#'): 30 | lines.append(line) 31 | continue 32 | 33 | m = re.match(r'../examples/(test[0-9]+) (.*) > tmp.out.*', line) 34 | if m: 35 | (test, args) = m.groups() 36 | lines.append("./simple-test.sh `basename $0 .sh` %s %s\n" 37 | % (test, args)) 38 | continue 39 | 40 | m = re.match(r'../examples/(test[0-9]+) > tmp.out.*', line) 41 | if m: 42 | test = m.group(1) 43 | args = "" 44 | lines.append("./simple-test.sh `basename $0 .sh` %s\n" 45 | % test) 46 | 47 | continue 48 | 49 | m = re.match(r'.*(test[0-9]+).out.*', line) 50 | if m: 51 | out = m.group(1) 52 | 53 | if not all([v != None for v in [out, test, args]]): 54 | print "Failed to parse", path 55 | print out, test, args 56 | return 57 | 58 | with open(path, 'w') as f: 59 | for line in lines: 60 | f.write(line) 61 | 62 | for path in sys.argv[1:]: 63 | process_file(path) 64 | -------------------------------------------------------------------------------- /scripts/modeline.py: -------------------------------------------------------------------------------- 1 | import sys 2 | 3 | modline = "// -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*-\n\n" 4 | 5 | for path in sys.argv[1:]: 6 | lines = [modline] 7 | with file(path) as f: 8 | lines += f.readlines() 9 | 10 | has_modeline = any([l for l in lines[1:] if l.find('Mode: c++') != -1]) 11 | if has_modeline: 12 | continue 13 | 14 | with file(path, 'w') as f: 15 | for line in lines: 16 | f.write(line) 17 | -------------------------------------------------------------------------------- /tclap.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@prefix@ 2 | includedir=@includedir@ 3 | 4 | Name: tclap 5 | Description: Templatized C++ Command Line Parser 6 | Version: @VERSION@ 7 | Cflags: -I${includedir} 8 | -------------------------------------------------------------------------------- /tests/Makefile.am: -------------------------------------------------------------------------------- 1 | 2 | 3 | TESTS = test1.sh \ 4 | test2.sh \ 5 | test3.sh \ 6 | test4.sh \ 7 | test5.sh \ 8 | test6.sh \ 9 | test7.sh \ 10 | test8.sh \ 11 | test9.sh \ 12 | test10.sh \ 13 | test11.sh \ 14 | test12.sh \ 15 | test13.sh \ 16 | test14.sh \ 17 | test15.sh \ 18 | test16.sh \ 19 | test17.sh \ 20 | test18.sh \ 21 | test19.sh \ 22 | test20.sh \ 23 | test21.sh \ 24 | test22.sh \ 25 | test23.sh \ 26 | test24.sh \ 27 | test25.sh \ 28 | test26.sh \ 29 | test27.sh \ 30 | test28.sh \ 31 | test29.sh \ 32 | test30.sh \ 33 | test31.sh \ 34 | test32.sh \ 35 | test33.sh \ 36 | test34.sh \ 37 | test35.sh \ 38 | test36.sh \ 39 | test37.sh \ 40 | test38.sh \ 41 | test39.sh \ 42 | test40.sh \ 43 | test41.sh \ 44 | test42.sh \ 45 | test43.sh \ 46 | test44.sh \ 47 | test45.sh \ 48 | test46.sh \ 49 | test47.sh \ 50 | test48.sh \ 51 | test49.sh \ 52 | test50.sh \ 53 | test51.sh \ 54 | test52.sh \ 55 | test53.sh \ 56 | test54.sh \ 57 | test55.sh \ 58 | test56.sh \ 59 | test57.sh \ 60 | test58.sh \ 61 | test59.sh \ 62 | test60.sh \ 63 | test61.sh \ 64 | test62.sh \ 65 | test63.sh \ 66 | test64.sh \ 67 | test65.sh \ 68 | test66.sh \ 69 | test67.sh \ 70 | test68.sh \ 71 | test69.sh \ 72 | test70.sh \ 73 | test71.sh \ 74 | test72.sh \ 75 | test73.sh \ 76 | test74.sh \ 77 | test75.sh \ 78 | test76.sh \ 79 | test77.sh \ 80 | test78.sh \ 81 | test79.sh \ 82 | test80.sh \ 83 | test81.sh \ 84 | test82.sh \ 85 | test83.sh \ 86 | test84.sh \ 87 | test85.sh \ 88 | test86.sh \ 89 | test87.sh \ 90 | test88.sh \ 91 | test89.sh \ 92 | test90.sh \ 93 | test91.sh 94 | 95 | EXTRA_DIST = $(TESTS) \ 96 | test1.out \ 97 | test2.out \ 98 | test3.out \ 99 | test4.out \ 100 | test5.out \ 101 | test6.out \ 102 | test7.out \ 103 | test8.out \ 104 | test9.out \ 105 | test10.out \ 106 | test11.out \ 107 | test12.out \ 108 | test13.out \ 109 | test14.out \ 110 | test15.out \ 111 | test16.out \ 112 | test17.out \ 113 | test18.out \ 114 | test19.out \ 115 | test20.out \ 116 | test21.out \ 117 | test22.out \ 118 | test23.out \ 119 | test24.out \ 120 | test25.out \ 121 | test26.out \ 122 | test27.out \ 123 | test28.out \ 124 | test29.out \ 125 | test30.out \ 126 | test31.out \ 127 | test32.out \ 128 | test33.out \ 129 | test34.out \ 130 | test35.out \ 131 | test36.out \ 132 | test37.out \ 133 | test38.out \ 134 | test39.out \ 135 | test40.out \ 136 | test41.out \ 137 | test42.out \ 138 | test43.out \ 139 | test44.out \ 140 | test45.out \ 141 | test46.out \ 142 | test47.out \ 143 | test48.out \ 144 | test49.out \ 145 | test50.out \ 146 | test51.out \ 147 | test52.out \ 148 | test53.out \ 149 | test54.out \ 150 | test55.out \ 151 | test56.out \ 152 | test57.out \ 153 | test58.out \ 154 | test59.out \ 155 | test60.out \ 156 | test61.out \ 157 | test62.out \ 158 | test63.out \ 159 | test64.out \ 160 | test65.out \ 161 | test66.out \ 162 | test67.out \ 163 | test68.out \ 164 | test69.out \ 165 | test70.out \ 166 | test71.out \ 167 | test72.out \ 168 | test73.out \ 169 | test74.out \ 170 | test75.out \ 171 | test76.out \ 172 | test77.out \ 173 | test78.out \ 174 | test79.out \ 175 | test80.out \ 176 | test81.out \ 177 | test82.out \ 178 | test83.out \ 179 | test84.out \ 180 | test85.out \ 181 | test86.out \ 182 | test87.out \ 183 | test88.out \ 184 | test89.out \ 185 | test90.out \ 186 | test91.out 187 | 188 | CLEANFILES = tmp.out 189 | -------------------------------------------------------------------------------- /tests/genOut.pl: -------------------------------------------------------------------------------- 1 | #!/usr/bin/perl 2 | # 3 | # Simple perl script to generate the expected output of test scripts. 4 | # This should never really be run. 5 | # If you do run it, make sure the output conforms to what you expect. 6 | # 7 | 8 | for ( $i = 1; $i <= $ARGV[0]; $i++ ) 9 | { 10 | system "test$i.sh; mv tmp.out test$i.out"; 11 | } 12 | -------------------------------------------------------------------------------- /tests/runtests.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Always run in script-dir 4 | DIR=`dirname $0` 5 | cd $DIR 6 | 7 | make check 8 | -------------------------------------------------------------------------------- /tests/simple-test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | if [ -z "$srcdir" ]; then 4 | srcdir=`dirname $0` 5 | fi 6 | 7 | TEST_RESULT=$srcdir/$1 8 | shift 9 | 10 | ../examples/"$@" 2>&1 | tee tmp.out 11 | 12 | if cmp -s tmp.out $TEST_RESULT.out; then 13 | echo "OK" 14 | exit 0 15 | else 16 | echo "FAIL" 17 | diff tmp.out $TEST_RESULT.out 18 | exit 1 19 | fi 20 | -------------------------------------------------------------------------------- /tests/test1.out: -------------------------------------------------------------------------------- 1 | My name (spelled backwards) is: ekim 2 | -------------------------------------------------------------------------------- /tests/test1.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | ./simple-test.sh test1 `basename $0 .sh` -r -n mike 4 | -------------------------------------------------------------------------------- /tests/test10.out: -------------------------------------------------------------------------------- 1 | PARSE ERROR: 2 | Required argument missing: unTest 3 | 4 | Brief USAGE: 5 | ../examples/test2 [-f ] -i -s [-A] [-C] [-B] [--] 6 | [--version] [-h] ... 7 | 8 | For complete USAGE and HELP type: 9 | ../examples/test2 --help 10 | 11 | -------------------------------------------------------------------------------- /tests/test10.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # failure 3 | ./simple-test.sh `basename $0 .sh` test2 -i 10 -s hello 4 | -------------------------------------------------------------------------------- /tests/test11.out: -------------------------------------------------------------------------------- 1 | PARSE ERROR: Argument: -i (--intTest) 2 | Argument already set! 3 | 4 | Brief USAGE: 5 | ../examples/test2 [-f ] -i -s [-A] [-C] [-B] [--] 6 | [--version] [-h] ... 7 | 8 | For complete USAGE and HELP type: 9 | ../examples/test2 --help 10 | 11 | -------------------------------------------------------------------------------- /tests/test11.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # failure 3 | ./simple-test.sh `basename $0 .sh` test2 -i 10 -s hello -i 9 4 | -------------------------------------------------------------------------------- /tests/test12.out: -------------------------------------------------------------------------------- 1 | PARSE ERROR: Argument: -f (--floatTest) 2 | Couldn't read argument value from string 'nine' 3 | 4 | Brief USAGE: 5 | ../examples/test2 [-f ] -i -s [-A] [-C] [-B] [--] 6 | [--version] [-h] ... 7 | 8 | For complete USAGE and HELP type: 9 | ../examples/test2 --help 10 | 11 | -------------------------------------------------------------------------------- /tests/test12.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # failure 3 | ./simple-test.sh `basename $0 .sh` test2 -i 10 -s hello -f nine 4 | -------------------------------------------------------------------------------- /tests/test13.out: -------------------------------------------------------------------------------- 1 | [-i] 0 9 2 | [-i] 1 8 3 | [ ] 0 bart 4 | for string we got : bill 5 | for ulabeled one we got : homer 6 | for ulabeled two we got : marge 7 | for bool B we got : 1 8 | -------------------------------------------------------------------------------- /tests/test13.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # success 3 | ./simple-test.sh `basename $0 .sh` test3 --stringTest=bill -i=9 -i=8 -B homer marge bart 4 | -------------------------------------------------------------------------------- /tests/test14.out: -------------------------------------------------------------------------------- 1 | [ ] 0 bart 2 | [ ] 1 one 3 | [ ] 2 two 4 | for string we got : aaa 5 | for ulabeled one we got : homer 6 | for ulabeled two we got : marge 7 | for bool B we got : 0 8 | -------------------------------------------------------------------------------- /tests/test14.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # success 3 | ./simple-test.sh `basename $0 .sh` test3 --stringTest=aaa homer marge bart -- one two 4 | -------------------------------------------------------------------------------- /tests/test15.out: -------------------------------------------------------------------------------- 1 | PARSE ERROR: Argument: (--stringTest) 2 | Couldn't find delimiter for this argument! 3 | 4 | Brief USAGE: 5 | ../examples/test3 [-f=] ... [-i=] ... --stringTest= 6 | [-B] [--] [--version] [-h] 7 | ... 8 | 9 | For complete USAGE and HELP type: 10 | ../examples/test3 --help 11 | 12 | -------------------------------------------------------------------------------- /tests/test15.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # failure 3 | ./simple-test.sh `basename $0 .sh` test3 --stringTest bbb homer marge bart -- -hv two 4 | -------------------------------------------------------------------------------- /tests/test16.out: -------------------------------------------------------------------------------- 1 | PARSE ERROR: Argument: (--stringTest) 2 | Couldn't find delimiter for this argument! 3 | 4 | Brief USAGE: 5 | ../examples/test3 [-f=] ... [-i=] ... --stringTest= 6 | [-B] [--] [--version] [-h] 7 | ... 8 | 9 | For complete USAGE and HELP type: 10 | ../examples/test3 --help 11 | 12 | -------------------------------------------------------------------------------- /tests/test16.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # failure 3 | ./simple-test.sh `basename $0 .sh` test3 --stringTest one homer -B -Bh 4 | -------------------------------------------------------------------------------- /tests/test17.out: -------------------------------------------------------------------------------- 1 | PARSE ERROR: 2 | Required argument missing: unTest2 3 | 4 | Brief USAGE: 5 | ../examples/test3 [-f=] ... [-i=] ... --stringTest= 6 | [-B] [--] [--version] [-h] 7 | ... 8 | 9 | For complete USAGE and HELP type: 10 | ../examples/test3 --help 11 | 12 | -------------------------------------------------------------------------------- /tests/test17.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # failure 3 | ./simple-test.sh `basename $0 .sh` test3 --stringTest=one homer -B 4 | -------------------------------------------------------------------------------- /tests/test18.out: -------------------------------------------------------------------------------- 1 | my failure message: 2 | -s -- Couldn't find match for argument 3 | -------------------------------------------------------------------------------- /tests/test18.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # failure 3 | ./simple-test.sh `basename $0 .sh` test4 -Bs --Bs asdf 4 | -------------------------------------------------------------------------------- /tests/test19.out: -------------------------------------------------------------------------------- 1 | for string we got : asdf 2 | for bool B we got : 1 3 | for bool A we got : 1 4 | -------------------------------------------------------------------------------- /tests/test19.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # success 3 | ./simple-test.sh `basename $0 .sh` test4 -BA --Bs asdf 4 | -------------------------------------------------------------------------------- /tests/test2.out: -------------------------------------------------------------------------------- 1 | My name is: mike 2 | -------------------------------------------------------------------------------- /tests/test2.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # success 3 | ./simple-test.sh `basename $0 .sh` test1 -n mike 4 | -------------------------------------------------------------------------------- /tests/test20.out: -------------------------------------------------------------------------------- 1 | for I: 2 | 0 sss 3 | 1 fdsf 4 | for A OR B we got : asdf 5 | for string C we got : fdas 6 | for string D we got : 0 7 | for E or F or G we got: blah 8 | -------------------------------------------------------------------------------- /tests/test20.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # success 3 | ./simple-test.sh `basename $0 .sh` test5 -a asdf -c fdas --eee blah -i sss -i fdsf 4 | -------------------------------------------------------------------------------- /tests/test21.out: -------------------------------------------------------------------------------- 1 | for J: 2 | 0 homer 3 | for A OR B we got : asdf 4 | for string C we got : fdas 5 | for string D we got : 0 6 | for E or F or G we got: asdf 7 | -------------------------------------------------------------------------------- /tests/test21.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # success 3 | ./simple-test.sh `basename $0 .sh` test5 -b asdf -c fdas -g asdf -j homer 4 | -------------------------------------------------------------------------------- /tests/test22.out: -------------------------------------------------------------------------------- 1 | PARSE ERROR: Argument: -b (--bbb) 2 | Mutually exclusive argument already set! 3 | 4 | Brief USAGE: 5 | ../examples/test5 {-a |-b } {--eee |--fff 6 | |-g } {-i ...|-j 7 | ...} [--ddd] -c [--] [--version] [-h] 8 | 9 | For complete USAGE and HELP type: 10 | ../examples/test5 --help 11 | 12 | -------------------------------------------------------------------------------- /tests/test22.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # failure 3 | ./simple-test.sh `basename $0 .sh` test5 -a fdsa -b asdf -c fdas 4 | -------------------------------------------------------------------------------- /tests/test23.out: -------------------------------------------------------------------------------- 1 | PARSE ERROR: Argument: -d 2 | Couldn't find match for argument 3 | 4 | Brief USAGE: 5 | ../examples/test5 {-a |-b } {--eee |--fff 6 | |-g } {-i ...|-j 7 | ...} [--ddd] -c [--] [--version] [-h] 8 | 9 | For complete USAGE and HELP type: 10 | ../examples/test5 --help 11 | 12 | -------------------------------------------------------------------------------- /tests/test23.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # failure 3 | ./simple-test.sh `basename $0 .sh` test5 -d junk -c fdas 4 | -------------------------------------------------------------------------------- /tests/test24.out: -------------------------------------------------------------------------------- 1 | PARSE ERROR: Argument: -b (--bbb) 2 | Mutually exclusive argument already set! 3 | 4 | Brief USAGE: 5 | ../examples/test5 {-a |-b } {--eee |--fff 6 | |-g } {-i ...|-j 7 | ...} [--ddd] -c [--] [--version] [-h] 8 | 9 | For complete USAGE and HELP type: 10 | ../examples/test5 --help 11 | 12 | -------------------------------------------------------------------------------- /tests/test24.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # failure 3 | ./simple-test.sh `basename $0 .sh` test5 --aaa dilbert -b asdf -c fdas 4 | -------------------------------------------------------------------------------- /tests/test25.out: -------------------------------------------------------------------------------- 1 | for I: 2 | 0 one 3 | 1 two 4 | for A OR B we got : asdf 5 | for string C we got : fdas 6 | for string D we got : 0 7 | for E or F or G we got: blah 8 | -------------------------------------------------------------------------------- /tests/test25.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # success 3 | ./simple-test.sh `basename $0 .sh` test5 --aaa asdf -c fdas --fff blah -i one -i two 4 | -------------------------------------------------------------------------------- /tests/test26.out: -------------------------------------------------------------------------------- 1 | PARSE ERROR: Argument: -f (--floatTest) 2 | More than one valid value parsed from string '4..2' 3 | 4 | Brief USAGE: 5 | ../examples/test2 [-f ] -i -s [-A] [-C] [-B] [--] 6 | [--version] [-h] ... 7 | 8 | For complete USAGE and HELP type: 9 | ../examples/test2 --help 10 | 11 | -------------------------------------------------------------------------------- /tests/test26.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # failure 3 | ./simple-test.sh `basename $0 .sh` test2 -i 2 -f 4..2 -s asdf asdf 4 | -------------------------------------------------------------------------------- /tests/test27.out: -------------------------------------------------------------------------------- 1 | PARSE ERROR: Argument: -f (--floatTest) 2 | More than one valid value parsed from string '4.0.2' 3 | 4 | Brief USAGE: 5 | ../examples/test2 [-f ] -i -s [-A] [-C] [-B] [--] 6 | [--version] [-h] ... 7 | 8 | For complete USAGE and HELP type: 9 | ../examples/test2 --help 10 | 11 | -------------------------------------------------------------------------------- /tests/test27.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # failure 3 | ./simple-test.sh `basename $0 .sh` test2 -i 2 -f 4.0.2 -s asdf asdf 4 | -------------------------------------------------------------------------------- /tests/test28.out: -------------------------------------------------------------------------------- 1 | PARSE ERROR: Argument: -i (--intTest) 2 | Couldn't read argument value from string '2a' 3 | 4 | Brief USAGE: 5 | ../examples/test2 [-f ] -i -s [-A] [-C] [-B] [--] 6 | [--version] [-h] ... 7 | 8 | For complete USAGE and HELP type: 9 | ../examples/test2 --help 10 | 11 | -------------------------------------------------------------------------------- /tests/test28.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # failure 3 | ./simple-test.sh `basename $0 .sh` test2 -i 2a -f 4.2 -s asdf asdf 4 | -------------------------------------------------------------------------------- /tests/test29.out: -------------------------------------------------------------------------------- 1 | PARSE ERROR: Argument: -i (--intTest) 2 | Couldn't read argument value from string '0xA' 3 | 4 | Brief USAGE: 5 | ../examples/test2 [-f ] -i -s [-A] [-C] [-B] [--] 6 | [--version] [-h] ... 7 | 8 | For complete USAGE and HELP type: 9 | ../examples/test2 --help 10 | 11 | -------------------------------------------------------------------------------- /tests/test29.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # failure... no hex here, but see test19.cpp for how to use hex 3 | ./simple-test.sh `basename $0 .sh` test2 -i 0xA -f 4.2 -s asdf asdf 4 | -------------------------------------------------------------------------------- /tests/test3.out: -------------------------------------------------------------------------------- 1 | My name (spelled backwards) is: ekim 2 | -------------------------------------------------------------------------------- /tests/test3.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # success 3 | ./simple-test.sh `basename $0 .sh` test1 -n mike -r 4 | -------------------------------------------------------------------------------- /tests/test30.out: -------------------------------------------------------------------------------- 1 | PARSE ERROR: Argument: -i (--intTest) 2 | Couldn't read argument value from string '2.1' 3 | 4 | Brief USAGE: 5 | ../examples/test2 [-f ] -i -s [-A] [-C] [-B] [--] 6 | [--version] [-h] ... 7 | 8 | For complete USAGE and HELP type: 9 | ../examples/test2 --help 10 | 11 | -------------------------------------------------------------------------------- /tests/test30.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # failure 3 | ./simple-test.sh `basename $0 .sh` test2 -i 2.1 -f 4.2 -s asdf asdf 4 | -------------------------------------------------------------------------------- /tests/test31.out: -------------------------------------------------------------------------------- 1 | PARSE ERROR: Argument: -i (--intTest) 2 | Couldn't read argument value from string '9a' 3 | 4 | Brief USAGE: 5 | ../examples/test3 [-f=] ... [-i=] ... --stringTest= 6 | [-B] [--] [--version] [-h] 7 | ... 8 | 9 | For complete USAGE and HELP type: 10 | ../examples/test3 --help 11 | 12 | -------------------------------------------------------------------------------- /tests/test31.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # failure 3 | ./simple-test.sh `basename $0 .sh` test3 -i=9a -i=1 -s=asdf asdf asdf 4 | -------------------------------------------------------------------------------- /tests/test32.out: -------------------------------------------------------------------------------- 1 | PARSE ERROR: Argument: -f (--floatTest) 2 | More than one valid value parsed from string '1.0.0' 3 | 4 | Brief USAGE: 5 | ../examples/test3 [-f=] ... [-i=] ... --stringTest= 6 | [-B] [--] [--version] [-h] 7 | ... 8 | 9 | For complete USAGE and HELP type: 10 | ../examples/test3 --help 11 | 12 | -------------------------------------------------------------------------------- /tests/test32.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # failure 3 | ./simple-test.sh `basename $0 .sh` test3 -f=9 -f=1.0.0 -s=asdf asdf asdf 4 | -------------------------------------------------------------------------------- /tests/test33.out: -------------------------------------------------------------------------------- 1 | for J: 2 | 0 o 3 | 1 t 4 | for A OR B we got : asdf 5 | for string C we got : fdas 6 | for string D we got : 1 7 | for E or F or G we got: blah 8 | -------------------------------------------------------------------------------- /tests/test33.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # success 3 | ./simple-test.sh `basename $0 .sh` test5 -a asdf -c fdas --eee blah --ddd -j o --jjj t 4 | -------------------------------------------------------------------------------- /tests/test34.out: -------------------------------------------------------------------------------- 1 | My name is homer 2 | My name is homer 3 | -------------------------------------------------------------------------------- /tests/test34.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # success 3 | ./simple-test.sh `basename $0 .sh` test6 -n homer 2 4 | -------------------------------------------------------------------------------- /tests/test35.out: -------------------------------------------------------------------------------- 1 | PARSE ERROR: Argument: -n (--name) 2 | Value 'mike' does not meet constraint: homer|marge|bart|lisa|maggie 3 | 4 | Brief USAGE: 5 | ../examples/test6 -n [--] [--version] 6 | [-h] <1|2|3> 7 | 8 | For complete USAGE and HELP type: 9 | ../examples/test6 --help 10 | 11 | -------------------------------------------------------------------------------- /tests/test35.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # failure 3 | ./simple-test.sh `basename $0 .sh` test6 -n mike 2 4 | -------------------------------------------------------------------------------- /tests/test36.out: -------------------------------------------------------------------------------- 1 | PARSE ERROR: Argument: (--times) 2 | Value '6' does not meet constraint: 1|2|3 3 | 4 | Brief USAGE: 5 | ../examples/test6 -n [--] [--version] 6 | [-h] <1|2|3> 7 | 8 | For complete USAGE and HELP type: 9 | ../examples/test6 --help 10 | 11 | -------------------------------------------------------------------------------- /tests/test36.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # failure 3 | ./simple-test.sh `basename $0 .sh` test6 -n homer 6 4 | -------------------------------------------------------------------------------- /tests/test37.out: -------------------------------------------------------------------------------- 1 | Got num 2 2 | Got num 1 3 | Got num 3 4 | Got name homer 5 | Got name marge 6 | -------------------------------------------------------------------------------- /tests/test37.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # success 3 | ./simple-test.sh `basename $0 .sh` test7 -n homer 2 -n marge 1 3 4 | -------------------------------------------------------------------------------- /tests/test38.out: -------------------------------------------------------------------------------- 1 | PARSE ERROR: Argument: -n (--name) 2 | Value 'mike' does not meet constraint: homer|marge|bart|lisa|maggie 3 | 4 | Brief USAGE: 5 | ThisIsAVeryLongProgramNameDesignedToTestSpacePrintWhichUsedToHaveProblem 6 | sWithLongProgramNamesIThinkItIsNowL 7 | ongEnough [-l ] [-u ] [-b ] [-z 9 | ] [-x ] [-s 10 | ] [-d] [-g ] [-f ] -n ... [--] 13 | [--version] [-h] <1|2|3> ... 14 | 15 | For complete USAGE and HELP type: 16 | ThisIsAVeryLongProgramNameDesignedToTestSpacePrintWhichUsedToHaveProblemsWithLongProgramNamesIThinkItIsNowLongEnough --help 17 | 18 | -------------------------------------------------------------------------------- /tests/test38.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # failure 3 | ./simple-test.sh `basename $0 .sh` test7 -n mike 2 1 4 | -------------------------------------------------------------------------------- /tests/test39.out: -------------------------------------------------------------------------------- 1 | PARSE ERROR: Argument: (--times) 2 | Value '6' does not meet constraint: 1|2|3 3 | 4 | Brief USAGE: 5 | ThisIsAVeryLongProgramNameDesignedToTestSpacePrintWhichUsedToHaveProblem 6 | sWithLongProgramNamesIThinkItIsNowL 7 | ongEnough [-l ] [-u ] [-b ] [-z 9 | ] [-x ] [-s 10 | ] [-d] [-g ] [-f ] -n ... [--] 13 | [--version] [-h] <1|2|3> ... 14 | 15 | For complete USAGE and HELP type: 16 | ThisIsAVeryLongProgramNameDesignedToTestSpacePrintWhichUsedToHaveProblemsWithLongProgramNamesIThinkItIsNowLongEnough --help 17 | 18 | -------------------------------------------------------------------------------- /tests/test39.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # failure 3 | ./simple-test.sh `basename $0 .sh` test7 2 -n homer -n bart 6 4 | -------------------------------------------------------------------------------- /tests/test4.out: -------------------------------------------------------------------------------- 1 | PARSE ERROR: 2 | Required argument missing: name 3 | 4 | Brief USAGE: 5 | ../examples/test1 [-r] -n [--] [--version] [-h] 6 | 7 | For complete USAGE and HELP type: 8 | ../examples/test1 --help 9 | 10 | -------------------------------------------------------------------------------- /tests/test4.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # failure 3 | ./simple-test.sh `basename $0 .sh` test1 4 | -------------------------------------------------------------------------------- /tests/test40.out: -------------------------------------------------------------------------------- 1 | 2 | USAGE: 3 | 4 | ../examples/test1 [-r] -n [--] [--version] [-h] 5 | 6 | 7 | Where: 8 | 9 | -r, --reverse 10 | Print name backwards 11 | 12 | -n , --name 13 | (required) Name to print 14 | 15 | --, --ignore_rest 16 | Ignores the rest of the labeled arguments following this flag. 17 | 18 | --version 19 | Displays version information and exits. 20 | 21 | -h, --help 22 | Displays usage information and exits. 23 | 24 | 25 | Command description message 26 | 27 | -------------------------------------------------------------------------------- /tests/test40.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # success 3 | ./simple-test.sh `basename $0 .sh` test1 --help 4 | -------------------------------------------------------------------------------- /tests/test41.out: -------------------------------------------------------------------------------- 1 | 2 | USAGE: 3 | 4 | ../examples/test2 [-f ] -i -s [-A] [-C] [-B] [--] 5 | [--version] [-h] ... 6 | 7 | 8 | Where: 9 | 10 | -f , --floatTest 11 | float test 12 | 13 | -i , --intTest 14 | (required) integer test 15 | 16 | -s , --stringTest 17 | (required) string test 18 | 19 | -A, --existTestA 20 | tests for the existence of A 21 | 22 | -C, --existTestC 23 | tests for the existence of C 24 | 25 | -B, --existTestB 26 | tests for the existence of B 27 | 28 | --, --ignore_rest 29 | Ignores the rest of the labeled arguments following this flag. 30 | 31 | --version 32 | Displays version information and exits. 33 | 34 | -h, --help 35 | Displays usage information and exits. 36 | 37 | 38 | (required) unlabeld test 39 | 40 | (accepted multiple times) 41 | file names 42 | 43 | 44 | this is a message 45 | 46 | -------------------------------------------------------------------------------- /tests/test41.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # success 3 | ./simple-test.sh `basename $0 .sh` test2 --help 4 | -------------------------------------------------------------------------------- /tests/test42.out: -------------------------------------------------------------------------------- 1 | 2 | USAGE: 3 | 4 | ../examples/test3 [-f=] ... [-i=] ... --stringTest= 5 | [-B] [--] [--version] [-h] 6 | ... 7 | 8 | 9 | Where: 10 | 11 | -f=, --floatTest= (accepted multiple times) 12 | multi float test 13 | 14 | -i=, --intTest= (accepted multiple times) 15 | multi int test 16 | 17 | --stringTest= 18 | (required) string test 19 | 20 | -B, --existTestB 21 | exist Test B 22 | 23 | --, --ignore_rest 24 | Ignores the rest of the labeled arguments following this flag. 25 | 26 | --version 27 | Displays version information and exits. 28 | 29 | -h, --help 30 | Displays usage information and exits. 31 | 32 | 33 | (required) unlabeled test one 34 | 35 | 36 | (required) unlabeled test two 37 | 38 | (accepted multiple times) 39 | file names 40 | 41 | 42 | this is a message 43 | 44 | -------------------------------------------------------------------------------- /tests/test42.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # success 3 | ./simple-test.sh `basename $0 .sh` test3 --help 4 | -------------------------------------------------------------------------------- /tests/test43.out: -------------------------------------------------------------------------------- 1 | my usage message: 2 | -A, --sA (exist Test A) 3 | -B, --sB (exist Test B) 4 | -s , --Bs ((required) string test) 5 | --, --ignore_rest (Ignores the rest of the labeled arguments following this flag.) 6 | --version (Displays version information and exits.) 7 | -h, --help (Displays usage information and exits.) 8 | -------------------------------------------------------------------------------- /tests/test43.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # success 3 | ./simple-test.sh `basename $0 .sh` test4 --help 4 | -------------------------------------------------------------------------------- /tests/test44.out: -------------------------------------------------------------------------------- 1 | 2 | USAGE: 3 | 4 | ../examples/test5 {-a |-b } {--eee |--fff 5 | |-g } {-i ...|-j 6 | ...} [--ddd] -c [--] [--version] [-h] 7 | 8 | 9 | Where: 10 | 11 | -a , --aaa 12 | (OR required) or test a 13 | -- OR -- 14 | -b , --bbb 15 | (OR required) or test b 16 | 17 | 18 | --eee 19 | (OR required) e test 20 | -- OR -- 21 | --fff 22 | (OR required) f test 23 | -- OR -- 24 | -g , --ggg 25 | (OR required) g test 26 | 27 | 28 | -i , --iii (accepted multiple times) 29 | (OR required) or test i 30 | -- OR -- 31 | -j , --jjj (accepted multiple times) 32 | (OR required) or test j 33 | 34 | 35 | --ddd 36 | d test 37 | 38 | -c , --ccc 39 | (required) c test 40 | 41 | --, --ignore_rest 42 | Ignores the rest of the labeled arguments following this flag. 43 | 44 | --version 45 | Displays version information and exits. 46 | 47 | -h, --help 48 | Displays usage information and exits. 49 | 50 | 51 | this is a message 52 | 53 | -------------------------------------------------------------------------------- /tests/test44.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # success 3 | ./simple-test.sh `basename $0 .sh` test5 --help 4 | -------------------------------------------------------------------------------- /tests/test45.out: -------------------------------------------------------------------------------- 1 | 2 | USAGE: 3 | 4 | ../examples/test6 -n [--] [--version] 5 | [-h] <1|2|3> 6 | 7 | 8 | Where: 9 | 10 | -n , --name 12 | (required) Name to print 13 | 14 | --, --ignore_rest 15 | Ignores the rest of the labeled arguments following this flag. 16 | 17 | --version 18 | Displays version information and exits. 19 | 20 | -h, --help 21 | Displays usage information and exits. 22 | 23 | <1|2|3> 24 | (required) Number of times to print 25 | 26 | 27 | Command description message 28 | 29 | -------------------------------------------------------------------------------- /tests/test45.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # success 3 | ./simple-test.sh `basename $0 .sh` test6 --help 4 | -------------------------------------------------------------------------------- /tests/test46.out: -------------------------------------------------------------------------------- 1 | 2 | USAGE: 3 | 4 | ThisIsAVeryLongProgramNameDesignedToTestSpacePrintWhichUsedToHaveProblem 5 | sWithLongProgramNamesIThinkItIsNowL 6 | ongEnough [-l ] [-u ] [-b ] [-z 8 | ] [-x ] [-s 9 | ] [-d] [-g ] [-f ] -n ... [--] 12 | [--version] [-h] <1|2|3> ... 13 | 14 | 15 | Where: 16 | 17 | -l , --limit 18 | Max number of alignments allowed 19 | 20 | -u , --upperBound 21 | upper percentage bound 22 | 23 | -b , --lowerBound 24 | lower percentage bound 25 | 26 | -z , --filename2 27 | Sequence 2 filename (FASTA format) 28 | 29 | -x , --filename1 30 | Sequence 1 filename (FASTA format) 31 | 32 | -s , --scoring--Matrix 33 | Scoring Matrix name 34 | 35 | -d, --isDna 36 | The input sequences are DNA 37 | 38 | -g , --gap-Extend 39 | The cost for each extension of a gap 40 | 41 | -f , --gapCreate 42 | The cost of creating a gap 43 | 44 | -n , --name (accepted multiple times) 46 | (required) Name to print. This is a long, nonsensical message to test 47 | line wrapping. Hopefully it works. 48 | 49 | --, --ignore_rest 50 | Ignores the rest of the labeled arguments following this flag. 51 | 52 | --version 53 | Displays version information and exits. 54 | 55 | -h, --help 56 | Displays usage information and exits. 57 | 58 | <1|2|3> (accepted multiple times) 59 | Number of times to print 60 | 61 | 62 | Command description message. This is a long multi-line message meant to 63 | test line wrapping. This is more text that doesn't really do anything 64 | besides take up lots of space that otherwise might be used for something 65 | real. That should be enough, don't you think? 66 | 67 | -------------------------------------------------------------------------------- /tests/test46.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # success 3 | ./simple-test.sh `basename $0 .sh` test7 --help 4 | -------------------------------------------------------------------------------- /tests/test47.out: -------------------------------------------------------------------------------- 1 | [-i] 0 9 2 | [-i] 1 8 3 | [ ] 0 bart 4 | for string we got : bill 5 | for ulabeled one we got : homer 6 | for ulabeled two we got : marge 7 | for bool B we got : 1 8 | -------------------------------------------------------------------------------- /tests/test47.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # success 3 | ./simple-test.sh `basename $0 .sh` test8 -s=bill -i=9 -i=8 -B homer marge bart 4 | -------------------------------------------------------------------------------- /tests/test48.out: -------------------------------------------------------------------------------- 1 | [ ] 0 bart 2 | [ ] 1 one 3 | [ ] 2 two 4 | for string we got : aaa 5 | for ulabeled one we got : homer 6 | for ulabeled two we got : marge 7 | for bool B we got : 0 8 | -------------------------------------------------------------------------------- /tests/test48.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # success 3 | ./simple-test.sh `basename $0 .sh` test8 -s=aaa homer marge bart -- one two 4 | -------------------------------------------------------------------------------- /tests/test49.out: -------------------------------------------------------------------------------- 1 | PARSE ERROR: Argument: -s (--stringTest) 2 | Couldn't find delimiter for this argument! 3 | 4 | Brief USAGE: 5 | ../examples/test8 [-f=] ... [-i=] ... -s= [-B] [--] 6 | [--version] [-h] 7 | ... 8 | 9 | For complete USAGE and HELP type: 10 | ../examples/test8 --help 11 | 12 | -------------------------------------------------------------------------------- /tests/test49.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # failure 3 | ./simple-test.sh `basename $0 .sh` test8 -s bbb homer marge bart -- -hv two 4 | -------------------------------------------------------------------------------- /tests/test5.out: -------------------------------------------------------------------------------- 1 | 0 bart 2 | 1 lisa 3 | for float we got : 3.7 4 | for int we got : 10 5 | for string we got : homer 6 | for ulabeled we got : marge 7 | for bool A we got : 0 8 | for bool B we got : 0 9 | for bool C we got : 0 10 | -------------------------------------------------------------------------------- /tests/test5.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # success 3 | ./simple-test.sh `basename $0 .sh` test2 -i 10 -s homer marge bart lisa 4 | -------------------------------------------------------------------------------- /tests/test50.out: -------------------------------------------------------------------------------- 1 | PARSE ERROR: Argument: -s (--stringTest) 2 | Couldn't find delimiter for this argument! 3 | 4 | Brief USAGE: 5 | ../examples/test8 [-f=] ... [-i=] ... -s= [-B] [--] 6 | [--version] [-h] 7 | ... 8 | 9 | For complete USAGE and HELP type: 10 | ../examples/test8 --help 11 | 12 | -------------------------------------------------------------------------------- /tests/test50.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # failure 3 | ./simple-test.sh `basename $0 .sh` test8 -s one homer -B -Bh 4 | -------------------------------------------------------------------------------- /tests/test51.out: -------------------------------------------------------------------------------- 1 | PARSE ERROR: 2 | Required argument missing: unTest2 3 | 4 | Brief USAGE: 5 | ../examples/test8 [-f=] ... [-i=] ... -s= [-B] [--] 6 | [--version] [-h] 7 | ... 8 | 9 | For complete USAGE and HELP type: 10 | ../examples/test8 --help 11 | 12 | -------------------------------------------------------------------------------- /tests/test51.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # failure 3 | ./simple-test.sh `basename $0 .sh` test8 -s=one homer -B 4 | -------------------------------------------------------------------------------- /tests/test52.out: -------------------------------------------------------------------------------- 1 | PARSE ERROR: Argument: -i (--intTest) 2 | Couldn't read argument value from string '9a' 3 | 4 | Brief USAGE: 5 | ../examples/test8 [-f=] ... [-i=] ... -s= [-B] [--] 6 | [--version] [-h] 7 | ... 8 | 9 | For complete USAGE and HELP type: 10 | ../examples/test8 --help 11 | 12 | -------------------------------------------------------------------------------- /tests/test52.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # failure 3 | ./simple-test.sh `basename $0 .sh` test8 -i=9a -i=1 -s=asdf asdf asdf 4 | -------------------------------------------------------------------------------- /tests/test53.out: -------------------------------------------------------------------------------- 1 | PARSE ERROR: Argument: -f (--floatTest) 2 | More than one valid value parsed from string '1.0.0' 3 | 4 | Brief USAGE: 5 | ../examples/test8 [-f=] ... [-i=] ... -s= [-B] [--] 6 | [--version] [-h] 7 | ... 8 | 9 | For complete USAGE and HELP type: 10 | ../examples/test8 --help 11 | 12 | -------------------------------------------------------------------------------- /tests/test53.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # failure 3 | ./simple-test.sh `basename $0 .sh` test8 -f=9 -f=1.0.0 -s=asdf asdf asdf 4 | -------------------------------------------------------------------------------- /tests/test54.out: -------------------------------------------------------------------------------- 1 | 2 | USAGE: 3 | 4 | ../examples/test8 [-f=] ... [-i=] ... -s= [-B] [--] 5 | [--version] [-h] 6 | ... 7 | 8 | 9 | Where: 10 | 11 | -f=, --floatTest= (accepted multiple times) 12 | multi float test 13 | 14 | -i=, --intTest= (accepted multiple times) 15 | multi int test 16 | 17 | -s=, --stringTest= 18 | (required) string test 19 | 20 | -B, --existTestB 21 | exist Test B 22 | 23 | --, --ignore_rest 24 | Ignores the rest of the labeled arguments following this flag. 25 | 26 | --version 27 | Displays version information and exits. 28 | 29 | -h, --help 30 | Displays usage information and exits. 31 | 32 | 33 | (required) unlabeled test one 34 | 35 | 36 | (required) unlabeled test two 37 | 38 | (accepted multiple times) 39 | file names 40 | 41 | 42 | this is a message 43 | 44 | -------------------------------------------------------------------------------- /tests/test54.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # success 3 | ./simple-test.sh `basename $0 .sh` test8 --help 4 | -------------------------------------------------------------------------------- /tests/test55.out: -------------------------------------------------------------------------------- 1 | [ ] 0 zero 2 | [ ] 1 one 3 | for string we got : asdf 4 | for ulabeled one we got : - 5 | for ulabeled two we got : asdf 6 | for bool B we got : 0 7 | -------------------------------------------------------------------------------- /tests/test55.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # success 3 | ./simple-test.sh `basename $0 .sh` test3 --stringTest=asdf - asdf zero one 4 | -------------------------------------------------------------------------------- /tests/test56.out: -------------------------------------------------------------------------------- 1 | 0 one 2 | 1 two 3 | for float we got : 3.7 4 | for int we got : 1 5 | for string we got : fdsa 6 | for ulabeled we got : - 7 | for bool A we got : 0 8 | for bool B we got : 0 9 | for bool C we got : 0 10 | -------------------------------------------------------------------------------- /tests/test56.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # success 3 | ./simple-test.sh `basename $0 .sh` test2 -i 1 - -s fdsa one two 4 | -------------------------------------------------------------------------------- /tests/test57.out: -------------------------------------------------------------------------------- 1 | PARSE ERROR: Argument: -i (--iii) 2 | Mutually exclusive argument already set! 3 | 4 | Brief USAGE: 5 | ../examples/test5 {-a |-b } {--eee |--fff 6 | |-g } {-i ...|-j 7 | ...} [--ddd] -c [--] [--version] [-h] 8 | 9 | For complete USAGE and HELP type: 10 | ../examples/test5 --help 11 | 12 | -------------------------------------------------------------------------------- /tests/test57.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # failure 3 | # This used to fail on the "Too many arguments!" but now fails sooner, 4 | # and on a more approriate error. 5 | ./simple-test.sh `basename $0 .sh` test5 --aaa asdf -c fdas --fff blah -i one -i two -j huh 6 | -------------------------------------------------------------------------------- /tests/test58.out: -------------------------------------------------------------------------------- 1 | FORWARD 2 | -------------------------------------------------------------------------------- /tests/test58.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # success 3 | ./simple-test.sh `basename $0 .sh` test9 4 | -------------------------------------------------------------------------------- /tests/test59.out: -------------------------------------------------------------------------------- 1 | REVERSE 2 | Verbose level: 3 3 | Noise level: 7 4 | Word: blah 5 | -------------------------------------------------------------------------------- /tests/test59.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # success 3 | ./simple-test.sh `basename $0 .sh` test9 -VVV -N --noise -r blah 4 | -------------------------------------------------------------------------------- /tests/test6.out: -------------------------------------------------------------------------------- 1 | for float we got : 3.7 2 | for int we got : 10 3 | for string we got : hello 4 | for ulabeled we got : goodbye 5 | for bool A we got : 1 6 | for bool B we got : 1 7 | for bool C we got : 1 8 | -------------------------------------------------------------------------------- /tests/test6.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # success 3 | ./simple-test.sh `basename $0 .sh` test2 -i 10 -s hello goodbye -ABC 4 | -------------------------------------------------------------------------------- /tests/test60.out: -------------------------------------------------------------------------------- 1 | PARSE ERROR: Argument: -r (--reverse) 2 | Argument already set! 3 | 4 | 5 | USAGE: 6 | 7 | ../examples/test9 [-N] ... [-V] ... [-r] [--] 8 | 9 | 10 | Where: 11 | 12 | -N, --noise (accepted multiple times) 13 | Level of noise 14 | 15 | -V, --verbose (accepted multiple times) 16 | Level of verbosity 17 | 18 | -r, --reverse 19 | REVERSE instead of FORWARDS 20 | 21 | --, --ignore_rest 22 | Ignores the rest of the labeled arguments following this flag. 23 | 24 | 25 | a random word 26 | 27 | 28 | Command description message 29 | 30 | -------------------------------------------------------------------------------- /tests/test60.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # failure 3 | ./simple-test.sh `basename $0 .sh` test9 -VVV -N --noise -rr 4 | -------------------------------------------------------------------------------- /tests/test61.out: -------------------------------------------------------------------------------- 1 | for float we got : 3.7 2 | for int we got : 10 3 | for string we got : hello 4 | for ulabeled we got : -1 -1 5 | for bool A we got : 0 6 | for bool B we got : 0 7 | for bool C we got : 0 8 | -------------------------------------------------------------------------------- /tests/test61.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # this tests a bug in handling of - chars in Unlabeled args 3 | # success 4 | ./simple-test.sh `basename $0 .sh` test2 -i 10 -s hello "-1 -1" 5 | -------------------------------------------------------------------------------- /tests/test62.out: -------------------------------------------------------------------------------- 1 | PARSE ERROR: 2 | Required arguments missing: intTest, stringTest, unTest 3 | 4 | Brief USAGE: 5 | ../examples/test2 [-f ] -i -s [-A] [-C] [-B] [--] 6 | [--version] [-h] ... 7 | 8 | For complete USAGE and HELP type: 9 | ../examples/test2 --help 10 | 11 | -------------------------------------------------------------------------------- /tests/test62.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # this tests whether all required args are listed as 3 | # missing when no arguments are specified 4 | # failure 5 | ./simple-test.sh `basename $0 .sh` test2 6 | -------------------------------------------------------------------------------- /tests/test63.out: -------------------------------------------------------------------------------- 1 | PARSE ERROR: 2 | Required argument missing: vect 3 | 4 | Brief USAGE: 5 | ../examples/test11 -v <3D vector> [--] [--version] [-h] 6 | 7 | For complete USAGE and HELP type: 8 | ../examples/test11 --help 9 | 10 | -------------------------------------------------------------------------------- /tests/test63.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # this tests whether all required args are listed as 3 | # missing when no arguments are specified 4 | # failure 5 | ./simple-test.sh `basename $0 .sh` test11 6 | -------------------------------------------------------------------------------- /tests/test64.out: -------------------------------------------------------------------------------- 1 | 1 2 3 2 | -------------------------------------------------------------------------------- /tests/test64.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # this tests whether all required args are listed as 3 | # missing when no arguments are specified 4 | # failure 5 | ./simple-test.sh `basename $0 .sh` test11 -v "1 2 3" 6 | -------------------------------------------------------------------------------- /tests/test65.out: -------------------------------------------------------------------------------- 1 | 1 2 3 2 | 4 5 6 3 | 7 8 9 4 | -1 0.2 0.4 5 | REVERSED 6 | -1 0.2 0.4 7 | 7 8 9 8 | 4 5 6 9 | 1 2 3 10 | -------------------------------------------------------------------------------- /tests/test65.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # this tests whether all required args are listed as 3 | # missing when no arguments are specified 4 | # failure 5 | ./simple-test.sh `basename $0 .sh` test12 -v "1 2 3" -v "4 5 6" -v "7 8 9" -v "-1 0.2 0.4" 6 | -------------------------------------------------------------------------------- /tests/test66.out: -------------------------------------------------------------------------------- 1 | PARSE ERROR: 2 | Required argument missing: vect 3 | 4 | Brief USAGE: 5 | ../examples/test12 -v <3D vector> ... [--] [--version] [-h] 6 | 7 | For complete USAGE and HELP type: 8 | ../examples/test12 --help 9 | 10 | -------------------------------------------------------------------------------- /tests/test66.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # this tests whether all required args are listed as 3 | # missing when no arguments are specified 4 | # failure 5 | ./simple-test.sh `basename $0 .sh` test12 6 | -------------------------------------------------------------------------------- /tests/test67.out: -------------------------------------------------------------------------------- 1 | PARSE ERROR: Argument: -v (--vect) 2 | a 1 0.3 is not a 3D vector 3 | 4 | Brief USAGE: 5 | ../examples/test12 -v <3D vector> ... [--] [--version] [-h] 6 | 7 | For complete USAGE and HELP type: 8 | ../examples/test12 --help 9 | 10 | -------------------------------------------------------------------------------- /tests/test67.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # this tests whether all required args are listed as 3 | # missing when no arguments are specified 4 | # failure 5 | ./simple-test.sh `basename $0 .sh` test12 -v "a 1 0.3" 6 | -------------------------------------------------------------------------------- /tests/test68.out: -------------------------------------------------------------------------------- 1 | module 2 | MultiSwtichArg was found 0 times. 3 | done... 4 | -------------------------------------------------------------------------------- /tests/test68.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # this tests whether we can parse args from 3 | # a vector of strings and that combined switch 4 | # handling doesn't get fooled if the delimiter 5 | # is in the string 6 | # success 7 | ./simple-test.sh `basename $0 .sh` test13 8 | -------------------------------------------------------------------------------- /tests/test69.out: -------------------------------------------------------------------------------- 1 | error: Couldn't find match for argument for arg Argument: --bob 2 | -------------------------------------------------------------------------------- /tests/test69.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Checks that parsing exceptions are properly 3 | # propagated to the caller. 4 | ./simple-test.sh `basename $0 .sh` test18 --bob 5 | -------------------------------------------------------------------------------- /tests/test7.out: -------------------------------------------------------------------------------- 1 | 2 | USAGE: 3 | 4 | ../examples/test2 [-f ] -i -s [-A] [-C] [-B] [--] 5 | [--version] [-h] ... 6 | 7 | 8 | Where: 9 | 10 | -f , --floatTest 11 | float test 12 | 13 | -i , --intTest 14 | (required) integer test 15 | 16 | -s , --stringTest 17 | (required) string test 18 | 19 | -A, --existTestA 20 | tests for the existence of A 21 | 22 | -C, --existTestC 23 | tests for the existence of C 24 | 25 | -B, --existTestB 26 | tests for the existence of B 27 | 28 | --, --ignore_rest 29 | Ignores the rest of the labeled arguments following this flag. 30 | 31 | --version 32 | Displays version information and exits. 33 | 34 | -h, --help 35 | Displays usage information and exits. 36 | 37 | 38 | (required) unlabeld test 39 | 40 | (accepted multiple times) 41 | file names 42 | 43 | 44 | this is a message 45 | 46 | -------------------------------------------------------------------------------- /tests/test7.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # success 3 | ./simple-test.sh `basename $0 .sh` test2 -i 10 -s hello goodbye -hABC 4 | -------------------------------------------------------------------------------- /tests/test70.out: -------------------------------------------------------------------------------- 1 | 2 | USAGE: 3 | 4 | ../examples/test18 [--] [--version] [-h] 5 | 6 | 7 | Where: 8 | 9 | --, --ignore_rest 10 | Ignores the rest of the labeled arguments following this flag. 11 | 12 | --version 13 | Displays version information and exits. 14 | 15 | -h, --help 16 | Displays usage information and exits. 17 | 18 | 19 | Command description message 20 | 21 | Exiting on ExitException. 22 | -------------------------------------------------------------------------------- /tests/test70.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Checks that parsing exceptions are properly 3 | # propagated to the caller. 4 | ./simple-test.sh `basename $0 .sh` test18 --help 5 | -------------------------------------------------------------------------------- /tests/test71.out: -------------------------------------------------------------------------------- 1 | found int: 10 2 | -------------------------------------------------------------------------------- /tests/test71.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # success test hex 3 | ./simple-test.sh `basename $0 .sh` test19 -i 0xA 4 | -------------------------------------------------------------------------------- /tests/test72.out: -------------------------------------------------------------------------------- 1 | found int: 10 2 | -------------------------------------------------------------------------------- /tests/test72.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # success test octal 3 | ./simple-test.sh `basename $0 .sh` test19 -i 012 4 | -------------------------------------------------------------------------------- /tests/test73.out: -------------------------------------------------------------------------------- 1 | for float we got : 3.7 2 | for int we got : 1 3 | for string we got : asdf 4 | for ulabeled we got : fff*fff 5 | for bool A we got : 0 6 | for bool B we got : 0 7 | for bool C we got : 0 8 | -------------------------------------------------------------------------------- /tests/test73.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # success tests whether * in UnlabeledValueArg passes 3 | ./simple-test.sh `basename $0 .sh` test2 -i 1 -s asdf fff*fff 4 | -------------------------------------------------------------------------------- /tests/test74.out: -------------------------------------------------------------------------------- 1 | PARSE ERROR: Argument: -b (--btmc) 2 | Mutually exclusive argument already set! 3 | 4 | Brief USAGE: 5 | ../examples/test20 {-a|-b} [--] [--version] [-h] 6 | 7 | For complete USAGE and HELP type: 8 | ../examples/test20 --help 9 | 10 | -------------------------------------------------------------------------------- /tests/test74.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # failure validates that the correct error message 3 | # is displayed for XOR'd args 4 | ./simple-test.sh `basename $0 .sh` test20 -a -b 5 | -------------------------------------------------------------------------------- /tests/test75.out: -------------------------------------------------------------------------------- 1 | PARSE ERROR: Argument: -a (--atmc) 2 | Mutually exclusive argument already set! 3 | 4 | Brief USAGE: 5 | ../examples/test20 {-a|-b} [--] [--version] [-h] 6 | 7 | For complete USAGE and HELP type: 8 | ../examples/test20 --help 9 | 10 | -------------------------------------------------------------------------------- /tests/test75.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # failure validates that the correct error message 3 | # is displayed for XOR'd args 4 | ./simple-test.sh `basename $0 .sh` test20 -b -a 5 | -------------------------------------------------------------------------------- /tests/test76.out: -------------------------------------------------------------------------------- 1 | PARSE ERROR: Argument: -b (--btmc) 2 | Mutually exclusive argument already set! 3 | 4 | Brief USAGE: 5 | ../examples/test20 {-a|-b} [--] [--version] [-h] 6 | 7 | For complete USAGE and HELP type: 8 | ../examples/test20 --help 9 | 10 | -------------------------------------------------------------------------------- /tests/test76.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # failure validates that the correct error message 3 | # is displayed for XOR'd args 4 | ./simple-test.sh `basename $0 .sh` test20 -ba 5 | -------------------------------------------------------------------------------- /tests/test77.out: -------------------------------------------------------------------------------- 1 | PARSE ERROR: Argument: -b (--btmc) 2 | Mutually exclusive argument already set! 3 | 4 | Brief USAGE: 5 | ../examples/test20 {-a|-b} [--] [--version] [-h] 6 | 7 | For complete USAGE and HELP type: 8 | ../examples/test20 --help 9 | 10 | -------------------------------------------------------------------------------- /tests/test77.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # failure validates that the correct error message 3 | # is displayed for XOR'd args 4 | ./simple-test.sh `basename $0 .sh` test20 -ab 5 | -------------------------------------------------------------------------------- /tests/test78.out: -------------------------------------------------------------------------------- 1 | My name (spelled backwards) is: ekim 2 | -------------------------------------------------------------------------------- /tests/test78.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # success 3 | ./simple-test.sh `basename $0 .sh` test21 ~~reverse /n mike 4 | -------------------------------------------------------------------------------- /tests/test79.out: -------------------------------------------------------------------------------- 1 | PARSE ERROR: 2 | Required argument missing: name 3 | 4 | Brief USAGE: 5 | ../examples/test21 [/r] /n [//] [~~version] [/h] 6 | 7 | For complete USAGE and HELP type: 8 | ../examples/test21 ~~help 9 | 10 | -------------------------------------------------------------------------------- /tests/test79.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # success 4 | ./simple-test.sh `basename $0 .sh` test21 5 | -------------------------------------------------------------------------------- /tests/test8.out: -------------------------------------------------------------------------------- 1 | 2 | ../examples/test2 version: 0.99 3 | 4 | -------------------------------------------------------------------------------- /tests/test8.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # success 3 | ./simple-test.sh `basename $0 .sh` test2 --version 4 | -------------------------------------------------------------------------------- /tests/test80.out: -------------------------------------------------------------------------------- 1 | My name is: mike 2 | -------------------------------------------------------------------------------- /tests/test80.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # success (everything but -n mike should be ignored) 4 | ../examples/test22 asdf -n mike asdf fds xxx > tmp.out 2>&1 5 | 6 | if cmp -s tmp.out $srcdir/test80.out; then 7 | exit 0 8 | else 9 | exit 1 10 | fi 11 | 12 | -------------------------------------------------------------------------------- /tests/test81.out: -------------------------------------------------------------------------------- 1 | PARSE ERROR: 2 | Required argument missing: name 3 | 4 | Brief USAGE: 5 | ../examples/test22 [-r] -n [--] [--version] [-h] 6 | 7 | For complete USAGE and HELP type: 8 | ../examples/test22 --help 9 | 10 | -------------------------------------------------------------------------------- /tests/test81.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # failure, still looking for -n 4 | ../examples/test22 asdf asdf -r fds xxx > tmp.out 2>&1 5 | 6 | if cmp -s tmp.out $srcdir/test81.out; then 7 | exit 0 8 | else 9 | exit 1 10 | fi 11 | 12 | -------------------------------------------------------------------------------- /tests/test82.out: -------------------------------------------------------------------------------- 1 | [-i] 0 9 2 | [-i] 1 8 3 | [ ] 0 blah 4 | [ ] 1 --blah 5 | [ ] 2 homer 6 | [ ] 3 marge 7 | [ ] 4 bart 8 | for string we got : bill 9 | for bool B we got : 1 10 | -------------------------------------------------------------------------------- /tests/test82.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # success - all unmatched args get slurped up in the UnlabeledMultiArg 4 | ../examples/test23 blah --blah -s=bill -i=9 -i=8 -B homer marge bart > tmp.out 2>&1 5 | 6 | if cmp -s tmp.out $srcdir/test82.out; then 7 | exit 0 8 | else 9 | exit 1 10 | fi 11 | 12 | -------------------------------------------------------------------------------- /tests/test83.out: -------------------------------------------------------------------------------- 1 | -nx (--name) -- Argument flag can only be one character long 2 | - (--name) -- Argument flag cannot be either '-' or '--' or a space. 3 | -- (--name) -- Argument flag cannot be either '-' or '--' or a space. 4 | --- (--name) -- Argument flag can only be one character long 5 | -n (-- ) -- Argument name begin with either '-' or '--' or space. 6 | -n (---) -- Argument name begin with either '-' or '--' or space. 7 | -n (----) -- Argument name begin with either '-' or '--' or space. 8 | -------------------------------------------------------------------------------- /tests/test83.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # success 4 | ../examples/test24 > tmp.out 2>&1 5 | 6 | if cmp -s tmp.out $srcdir/test83.out; then 7 | exit 0 8 | else 9 | exit 1 10 | fi 11 | 12 | -------------------------------------------------------------------------------- /tests/test84.out: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | test25 8 | 1 9 | 10 | 11 | test25 12 | this is a message 13 | 14 | 15 | 16 | test25 17 | 18 | -s string 19 | -B 20 | 21 | -A 22 | -- 23 | --version 24 | -h 25 | 26 | 27 | 28 | Description 29 | 30 | this is a message 31 | 32 | 33 | 34 | Options 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | exist Test A 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | (OR required) exist Test B 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | (OR required) string test 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | Ignores the rest of the labeled arguments following this flag. 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | Displays version information and exits. 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | Displays usage information and exits. 108 | 109 | 110 | 111 | 112 | 113 | 114 | Version 115 | 116 | 0.99 117 | 118 | 119 | 120 | -------------------------------------------------------------------------------- /tests/test84.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # docbookoutput. The when this test fails due to e.g. formatting 4 | # changes the results needs to be manually reviewed and the test81.out 5 | # updated 6 | ../examples/test25 -h x > tmp.out 2>&1 7 | 8 | if cmp -s tmp.out $srcdir/test84.out; then 9 | exit 0 10 | else 11 | exit 1 12 | fi 13 | 14 | -------------------------------------------------------------------------------- /tests/test85.out: -------------------------------------------------------------------------------- 1 | #compdef test25 2 | 3 | # test25 version 0.99 4 | 5 | _arguments -s -S \ 6 | '*(-A --sA)'{-A,--sA}'[exist Test A]:integer' \ 7 | '(-s --Bs -B --sB)'{-B,--sB}'[exist Test B]' \ 8 | '(-s --Bs -B --sB)'{-s,--Bs}'[string test]:string' \ 9 | '(-)--version[displays version information and exits]' \ 10 | '(-)'{-h,--help}'[displays usage information and exits]' 11 | -------------------------------------------------------------------------------- /tests/test85.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # zshcompletionoutput. The when this test fails due to e.g. formatting 4 | # changes the results needs to be manually reviewed and the test81.out 5 | # updated 6 | ../examples/test25 -h > tmp.out 2>&1 7 | 8 | if cmp -s tmp.out $srcdir/test85.out; then 9 | exit 0 10 | else 11 | exit 1 12 | fi 13 | 14 | -------------------------------------------------------------------------------- /tests/test86.out: -------------------------------------------------------------------------------- 1 | 3.2, -47.11, 0, 2 | -------------------------------------------------------------------------------- /tests/test86.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | ../examples/test14 -v "3.2 -47.11 0" > tmp.out 2>&1 4 | 5 | if cmp -s tmp.out $srcdir/test86.out; then 6 | exit 0 7 | else 8 | exit 1 9 | fi 10 | -------------------------------------------------------------------------------- /tests/test87.out: -------------------------------------------------------------------------------- 1 | 1 2 3 2 | -------------------------------------------------------------------------------- /tests/test87.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # this tests whether all required args are listed as 4 | # missing when no arguments are specified 5 | # failure 6 | ../examples/test26 -v "1 2 3" > tmp.out 2>&1 7 | 8 | if cmp -s tmp.out $srcdir/test87.out; then 9 | exit 0 10 | else 11 | exit 1 12 | fi 13 | -------------------------------------------------------------------------------- /tests/test88.out: -------------------------------------------------------------------------------- 1 | for falseSwitch we got : 0 2 | for trueSwitch we got : 1 3 | for strArg we got : defStr 4 | for intArg we got : 4711 5 | -------------------------------------------------------------------------------- /tests/test88.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ../examples/test27 > tmp.out 2>&1 4 | 5 | if cmp -s tmp.out $srcdir/test88.out; then 6 | exit 0 7 | else 8 | exit 1 9 | fi 10 | -------------------------------------------------------------------------------- /tests/test89.out: -------------------------------------------------------------------------------- 1 | Passed 2 | -------------------------------------------------------------------------------- /tests/test89.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ../examples/test28 > tmp.out 2>&1 4 | 5 | if cmp -s tmp.out $srcdir/test89.out; then 6 | exit 0 7 | else 8 | exit 1 9 | fi 10 | -------------------------------------------------------------------------------- /tests/test9.out: -------------------------------------------------------------------------------- 1 | 0 -hv 2 | 1 one 3 | 2 two 4 | for float we got : 3.7 5 | for int we got : 10 6 | for string we got : hello 7 | for ulabeled we got : goodbye 8 | for bool A we got : 0 9 | for bool B we got : 0 10 | for bool C we got : 0 11 | -------------------------------------------------------------------------------- /tests/test9.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # success 3 | ./simple-test.sh `basename $0 .sh` test2 -i 10 -s hello goodbye -- -hv one two 4 | -------------------------------------------------------------------------------- /tests/test90.out: -------------------------------------------------------------------------------- 1 | PARSE ERROR: 2 | The args vector must not be empty, the first entry should contain the program's name. 3 | 4 | Brief USAGE: 5 | not_set_yet [--] [--version] [-h] 6 | 7 | For complete USAGE and HELP type: 8 | not_set_yet --help 9 | 10 | -------------------------------------------------------------------------------- /tests/test90.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ../examples/test29 > tmp.out 2>&1 4 | 5 | if cmp -s tmp.out $srcdir/test90.out; then 6 | exit 0 7 | else 8 | exit 1 9 | fi 10 | -------------------------------------------------------------------------------- /tests/test91.out: -------------------------------------------------------------------------------- 1 | 1 2.3 2 | -------------------------------------------------------------------------------- /tests/test91.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ../examples/test30 -p "1 2.3" > tmp.out 2>&1 4 | 5 | if cmp -s tmp.out $srcdir/test91.out; then 6 | exit 0 7 | else 8 | exit 1 9 | fi 10 | -------------------------------------------------------------------------------- /tests/testCheck.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # 4 | # A script to easily compare the output of old test results and new. 5 | # 6 | if [ "$1" == "" ] 7 | then 8 | echo "USAGE: testCheck.sh " 9 | else 10 | cmd="sh ./test$1.sh" 11 | out="test$1.out" 12 | $cmd 13 | if cmp -s tmp.out $out 14 | then 15 | echo "$cmd OK -- output identical" 16 | else 17 | echo "$cmd Problem!" 18 | echo 19 | echo "TEST ======================================================" 20 | echo 21 | cat tmp.out 22 | echo "EXPECTED ==================================================" 23 | echo 24 | cat $out 25 | echo 26 | echo "DIFF ======================================================" 27 | echo "diff tmp.out $out" 28 | echo "< = test(new) = tmp.out" 29 | echo "> = expected = $out" 30 | echo 31 | diff tmp.out $out 32 | echo 33 | exit 1 34 | fi 35 | fi 36 | --------------------------------------------------------------------------------