tclap 1.6.0
CmdLine.h
Go to the documentation of this file.
1// -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*-
2
3/******************************************************************************
4 *
5 * file: CmdLine.h
6 *
7 * Copyright (c) 2003, Michael E. Smoot .
8 * Copyright (c) 2004, Michael E. Smoot, Daniel Aarno.
9 * Copyright (c) 2018, 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_CMD_LINE_H
26#define TCLAP_CMD_LINE_H
27
29#include <tclap/SwitchArg.h>
32
33#include <tclap/HelpVisitor.h>
36
37#include <tclap/CmdLineOutput.h>
38#include <tclap/StdOutput.h>
39
40#include <tclap/Constraint.h>
45
46#include <tclap/ArgGroup.h>
47#include <tclap/DeferDelete.h>
48
49#include <algorithm>
50#include <cstdlib>
51#include <iomanip>
52#include <iostream>
53#include <list>
54#include <memory>
55#include <string>
56#include <utility>
57#include <vector>
58
59namespace TCLAP {
60
61class StandaloneArgs : public AnyOf {
62public:
63 StandaloneArgs() = default;
64
65 ArgContainer &add(Arg *arg) override {
66 if (std::ranges::any_of(*this, [arg](const Arg *existing) {
67 return arg->conflictsWith(*existing);
68 })) {
70 "Argument with same flag/name already exists!",
71 arg->longID());
72 }
73
74 _args.push_back(arg);
75
76 return *this;
77 }
78
79 [[nodiscard]] bool showAsGroup() const override { return false; }
80};
81
86class CmdLine : public CmdLineInterface {
87protected:
92 std::list<Arg *> _argList;
93
95 StandaloneArgs _autoArgs; // --help, --version, etc
96
101 std::list<ArgGroup *> _argGroups;
102
106 std::string _progName;
107
111 std::string _message;
112
116 std::string _version;
117
124
130
131 // Registration order, scoped to this parser rather than construction.
134 class Registration;
135 bool attachGroup(ArgGroup &group) override {
136 add(group);
137 return true;
138 }
139
146
151
156
161
166 virtual ~MessageTranslator() = default;
167 [[nodiscard]] virtual std::string translate(
168 const std::string &messageId, const std::string &fallback) const = 0;
169 };
170
171 template <typename T>
174 MessageTranslatorImpl(const T &translator) : _translator(translator) {}
175 [[nodiscard]] std::string translate(
176 const std::string &messageId,
177 const std::string &fallback) const override {
178 return _translator(messageId, fallback);
179 }
180 };
181
182 std::unique_ptr<MessageTranslator> _messageTranslator;
183
191
195 void missingArgsException(const std::list<ArgGroup *> &missing);
196
203 bool _emptyCombined(const std::string &s);
204
205public:
209 CmdLine(const CmdLine &rhs) = delete;
210 CmdLine &operator=(const CmdLine &rhs) = delete;
211
212private:
217 void _constructor();
218 void _createIgnoreRestArgument();
219 void _createHelpAndVersionArguments();
220 void _refreshBuiltinDescriptions();
221
222 void _setProgramName(std::vector<std::string> &args);
223 int _parseArguments(std::vector<std::string> &args);
224 bool _processArgument(int &index, std::vector<std::string> &args,
225 int &requiredCount);
226 void _validateRequiredArguments(int requiredCount);
227
231 bool _helpAndVersion;
232
236 bool _ignoreUnmatched;
237
241 bool _ignoring;
242
243public:
256 CmdLine(std::string message, const char delimiter = ' ',
257 std::string version = "none", bool helpAndVersion = true);
258
262 ~CmdLine() override = default;
263
270 ArgContainer &add(Arg &a) override;
271
278 ArgContainer &add(Arg *a) override;
279
290 ArgContainer &add(ArgGroup &args) override;
291
292 // Internal, do not use
293 void addToArgList(Arg *a) override;
294
298 void xorAdd(Arg &a, Arg &b) override;
299
303 void xorAdd(const std::vector<Arg *> &xors) override;
304
310 void parse(int argc, const char *const *argv) override;
311
317 void parse(std::vector<std::string> &args);
318
319 void setOutput(CmdLineOutput *co) override;
320
321 [[nodiscard]] std::string getVersion() const override { return _version; }
322
323 [[nodiscard]] std::string getProgramName() const override {
324 return _progName;
325 }
326
327 // TOOD: Get rid of getArgList
328 [[nodiscard]] std::list<Arg *> getArgList() const override {
329 return _argList;
330 }
331 std::list<ArgGroup *> getArgGroups() override {
332 std::list<ArgGroup *> groups = _argGroups;
333 groups.push_back(&_autoArgs);
334 return groups;
335 }
336
337 [[nodiscard]] char getDelimiter() const override { return _delimiter; }
338 [[nodiscard]] std::string getMessage() const override { return _message; }
339 [[nodiscard]] bool hasHelpAndVersion() const override {
340 return _helpAndVersion;
341 }
342
348 void setExceptionHandling(const bool state);
349
356 [[nodiscard]] bool hasExceptionHandling() const {
357 return _handleExceptions;
358 }
359
363 void reset() override;
364
371 void ignoreUnmatched(const bool ignore);
372
376 template <typename T>
377 void setMessageTranslator(const T &translator) {
378 _messageTranslator = std::make_unique<MessageTranslatorImpl<T>>(translator);
379 _refreshBuiltinDescriptions();
380 }
381
385 [[nodiscard]] std::string translateMessage(
386 const std::string &messageId,
387 const std::string &fallback) const override {
388 if (_messageTranslator != nullptr) {
389 return _messageTranslator->translate(messageId, fallback);
390 }
391 return fallback;
392 }
393
394 void beginIgnoring() override { _ignoring = true; }
395 bool ignoreRest() override { return _ignoring; }
396};
397
399// Begin CmdLine.cpp
401
402inline CmdLine::CmdLine(std::string m, char delim, std::string v, bool help)
403 : _argList(),
404 _standaloneArgs(),
405 _autoArgs(),
406 _argGroups(),
407 _progName("not_set_yet"),
408 _message(std::move(m)),
409 _version(std::move(v)),
410 _numRequired(0),
411 _delimiter(delim),
412 _hasOptionalUnlabeledArg(false),
413 _registrationActive(false),
414 _deleteOnExit(),
415 _defaultOutput(),
416 _output(&_defaultOutput),
417 _handleExceptions(true),
418 _messageTranslator(nullptr),
419 _ignoreArg(nullptr),
420 _helpArg(nullptr),
421 _versionArg(nullptr),
422 _helpAndVersion(help),
423 _ignoreUnmatched(false),
424 _ignoring(false) {
425 _constructor();
426}
427
428inline void CmdLine::_constructor() {
430 _autoArgs._parser = this;
431 _createIgnoreRestArgument();
432 if (_helpAndVersion) _createHelpAndVersionArguments();
433}
434
435inline void CmdLine::_createIgnoreRestArgument() {
436 Visitor *v = new IgnoreRestVisitor(*this);
437 auto *ignore = new SwitchArg(
439 translateMessage("ignore_rest_description",
440 "Ignores the rest of the labeled arguments following this flag."),
441 false, v);
442 _ignoreArg = ignore;
443 _deleteOnExit(ignore);
444 _deleteOnExit(v);
445 _autoArgs.add(ignore);
446 CmdLine::addToArgList(ignore);
447}
448
449inline void CmdLine::_createHelpAndVersionArguments() {
450 Visitor *v = new HelpVisitor(this, &_output);
451 auto *help =
452 new SwitchArg("h", "help",
453 translateMessage("help_description",
454 "Displays usage information and exits."),
455 false, v);
456 _helpArg = help;
457 _deleteOnExit(help);
458 _deleteOnExit(v);
459
460 v = new VersionVisitor(this, &_output);
461 auto *vers = new SwitchArg(
462 "", "version",
463 translateMessage("version_description",
464 "Displays version information and exits."),
465 false, v);
466 _versionArg = vers;
467 _deleteOnExit(vers);
468 _deleteOnExit(v);
469
470 // Retain the established registration order used by help output.
471 _autoArgs.add(vers);
473 _autoArgs.add(help);
475}
476
477inline void CmdLine::_refreshBuiltinDescriptions() {
478 if (_ignoreArg != nullptr) {
480 "ignore_rest_description",
481 "Ignores the rest of the labeled arguments following this flag."));
482 }
483 if (_helpArg != nullptr) {
485 "help_description", "Displays usage information and exits."));
486 }
487 if (_versionArg != nullptr) {
489 "version_description", "Displays version information and exits."));
490 }
491}
492
493inline void CmdLine::_setProgramName(std::vector<std::string> &args) {
494 if (args.empty()) {
495 // https://sourceforge.net/p/tclap/bugs/30/
496 throw CmdLineParseException(
497 "The args vector must not be empty, "
498 "the first entry should contain the "
499 "program's name.");
500 }
501
502 // TODO(macbishop): Maybe store the full name somewhere?
503 _progName = basename(args.front());
504 args.erase(args.begin());
505}
506
507inline int CmdLine::_parseArguments(std::vector<std::string> &args) {
508 int requiredCount = 0;
509 for (int i = 0; static_cast<unsigned int>(i) < args.size(); i++) {
510 bool matched = _processArgument(i, args, requiredCount);
511
512 // checks to see if the argument is an empty combined
513 // switch and if so, then we've actually matched it
514 if (!matched && _emptyCombined(args[i])) matched = true;
515
516 if (!matched && !ignoreRest() && !_ignoreUnmatched)
517 throw(
518 CmdLineParseException("Couldn't find match "
519 "for argument",
520 args[i]));
521 }
522
523 return requiredCount;
524}
525
526inline bool CmdLine::_processArgument(int &index,
527 std::vector<std::string> &args,
528 int &requiredCount) {
529 for (Arg *argPtr : _argList) {
530 Arg &arg = *argPtr;
531 // Count a required argument only on its first match.
532 bool alreadySet = arg.isSet();
533 bool ignore = arg.isIgnoreable() && ignoreRest();
534 if (!ignore && arg.processArg(&index, args)) {
535 requiredCount += (!alreadySet && arg.isRequired()) ? 1 : 0;
536 return true;
537 }
538 }
539
540 return false;
541}
542
543inline void CmdLine::_validateRequiredArguments(int requiredCount) {
544 std::list<ArgGroup *> missingArgGroups;
545 // Once all arguments have been parsed, check that we don't
546 // violate any constraints.
547 for (ArgGroup *group : _argGroups) {
548 bool missingRequired = group->validate();
549 if (missingRequired) {
550 missingArgGroups.push_back(group);
551 }
552 }
553
554 if (requiredCount < _numRequired || !missingArgGroups.empty()) {
555 missingArgsException(missingArgGroups);
556 }
557
558 if (requiredCount > _numRequired) {
559 throw(CmdLineParseException(
560 translateMessage("too_many_arguments", "Too many arguments!")));
561 }
562}
563
564inline void CmdLine::xorAdd(const std::vector<Arg *> &args) {
565 auto *group = new OneOf(*this);
566 _deleteOnExit(group);
567
568 for (Arg *arg : args) {
569 group->add(*arg);
570 }
571}
572
573inline void CmdLine::xorAdd(Arg &a, Arg &b) {
574 std::vector<Arg *> ors;
575 ors.push_back(&a);
576 ors.push_back(&b);
577 xorAdd(ors);
578}
579
580// Insertion hooks run against a private list. Bindings are
581// temporarily visible to hooks and restored unless the whole operation commits.
583public:
584 explicit Registration(CmdLine &cmd)
585 : _cmd(cmd), _args(cmd._argList), _numRequired(cmd._numRequired),
586 _hasOptionalUnlabeledArg(cmd._hasOptionalUnlabeledArg), _bindings() {
587 if (_cmd._registrationActive)
588 throw SpecificationException("Argument registration cannot be re-entered");
589 _cmd._registrationActive = true;
590 }
591
592 Registration(const Registration &) = delete;
594
595 ~Registration() noexcept {
596 for (auto it = _bindings.rbegin();
597 it != _bindings.rend(); ++it)
598 it->first->_parserDelimiter = it->second;
599 _cmd._registrationActive = false;
600 }
601
602 void add(Arg &arg) {
603 arg._validateAliases(_cmd._delimiter, Arg::flagStartString(),
605 validateConflicts(arg);
606 validatePositionalOrder(arg);
607 _bindings.emplace_back(&arg, arg._parserDelimiter);
608 arg._parserDelimiter = &_cmd._delimiter;
609 arg.addToList(_args);
610 if (arg.isRequired()) ++_numRequired;
611 }
612
613 void commit() noexcept {
614 _cmd._argList.swap(_args);
615 _cmd._numRequired = _numRequired;
616 _cmd._hasOptionalUnlabeledArg = _hasOptionalUnlabeledArg;
617 _bindings.clear();
618 }
619
620private:
621 void validateConflicts(const Arg &arg) const {
622 if (std::ranges::any_of(_args, [&arg](const Arg *existing) {
623 return arg.conflictsWith(*existing) ||
624 arg._aliasConflictsWith(*existing, Arg::flagStartString(),
626 existing->_aliasConflictsWith(arg, Arg::flagStartString(),
628 })) {
630 "Argument with same flag/name already exists!", arg.longID());
631 }
632 }
633
634 void validatePositionalOrder(Arg &arg) {
635 if (!arg.hasLabel()) {
636 if (_hasOptionalUnlabeledArg)
637 throw SpecificationException(
638 "You can't specify ANY Unlabeled Arg following an optional "
639 "Unlabeled Arg", arg.longID());
640 if (!arg.isRequired() && !arg.acceptsMultipleValues())
641 _hasOptionalUnlabeledArg = true;
642 }
643 }
644
645 using Bindings = std::vector<std::pair<Arg *, const char *>>;
646 CmdLine &_cmd;
647 std::list<Arg *> _args;
648 int _numRequired;
649 bool _hasOptionalUnlabeledArg;
650 Bindings _bindings;
651};
652
654 if (group._parser)
655 throw SpecificationException("Arg group can have only one parser");
656 std::list<ArgGroup *> groups(_argGroups);
657 groups.push_back(&group);
658 Registration registration(*this);
659 for (Arg *arg : group) registration.add(*arg);
660 group._parser = this;
661 _argGroups.swap(groups);
662 registration.commit();
663 return *this;
664}
665
666inline ArgContainer &CmdLine::add(Arg &a) { return add(&a); }
667
668inline void CmdLine::addToArgList(Arg *a) {
669 Registration registration(*this);
670 registration.add(*a);
671 registration.commit();
672}
673
676 members.push_back(a);
677 Registration registration(*this);
678 registration.add(*a);
679 _standaloneArgs._args.swap(members);
680 registration.commit();
681 return *this;
682}
683
684inline void CmdLine::parse(int argc, const char *const *argv) {
685 // this step is necessary so that we have easy access to
686 // mutable strings.
687 std::vector<std::string> args(argv, argv + argc);
688
689 parse(args);
690}
691
692inline void CmdLine::parse(std::vector<std::string> &args) {
693 bool shouldExit = false;
694 int estat = 0;
695
696 try {
697 _setProgramName(args);
698 const int requiredCount = _parseArguments(args);
699 _validateRequiredArguments(requiredCount);
700 } catch (ArgException &e) {
701 // If we're not handling the exceptions, rethrow.
702 if (!_handleExceptions) {
703 throw;
704 }
705
706 try {
707 _output->failure(*this, e);
708 } catch (ExitException &ee) {
709 estat = ee.getExitStatus();
710 shouldExit = true;
711 }
712 } catch (ExitException &ee) {
713 // If we're not handling the exceptions, rethrow.
714 if (!_handleExceptions) {
715 throw;
716 }
717
718 estat = ee.getExitStatus();
719 shouldExit = true;
720 }
721
722 if (shouldExit) exit(estat);
723}
724
725inline bool CmdLine::_emptyCombined(const std::string &s) {
726 if (!s.empty() && s[0] != Arg::flagStartChar()) return false;
727
728 return s.find_first_not_of(Arg::blankChar(), 1) == std::string::npos;
729}
730
732 const std::list<ArgGroup *> &missing) {
733 int count = 0;
734
735 std::string missingArgList;
736 for (Arg *arg : _argList) {
737 if (arg->isRequired() && !arg->isSet()) {
738 missingArgList += arg->getName();
739 missingArgList += ", ";
740 count++;
741 }
742 }
743
744 for (const ArgGroup *group : missing) {
745 missingArgList += group->getName();
746 missingArgList += ", ";
747 count++;
748 }
749
750 missingArgList = missingArgList.substr(0, missingArgList.length() - 2);
751
752 std::string msg;
753 if (count > 1)
754 msg = translateMessage("required_arguments_missing",
755 "Required arguments missing: ");
756 else
757 msg = translateMessage("required_argument_missing",
758 "Required argument missing: ");
759
760 msg += missingArgList;
761
762 throw(CmdLineParseException(msg));
763}
764
765inline void CmdLine::setOutput(CmdLineOutput *co) { _output = co; }
766
767inline void CmdLine::setExceptionHandling(const bool state) {
768 _handleExceptions = state;
769}
770
771inline void CmdLine::reset() {
772 _ignoring = false;
773 for (Arg *arg : _argList) arg->reset();
774
775 _progName.clear();
776}
777
778inline void CmdLine::ignoreUnmatched(const bool ignore) {
779 _ignoreUnmatched = ignore;
780}
781
783// End CmdLine.cpp
785
786} // namespace TCLAP
787
788#endif // TCLAP_CMD_LINE_H
Groups arguments for presentation without imposing a selection rule.
Definition ArgGroup.h:185
Interface that allows adding an Arg to a "container".
A simple class that defines and argument exception.
ArgGroup is the base class for implementing groups of arguments that are mutually exclusive (it repla...
Definition ArgGroup.h:42
CmdLineInterface * _parser
Definition ArgGroup.h:126
Container _args
Definition ArgGroup.h:127
std::list< Arg * > Container
Definition ArgGroup.h:46
A virtual base class that defines the essential data for all arguments.
Definition Arg.h:69
static std::string flagStartString()
Definition Arg.h:266
virtual std::string longID(const std::string &valueId="val") const
Returns a long ID for the usage.
Definition Arg.h:603
bool conflictsWith(const Arg &a) const noexcept
Checks declared registration conflicts: the same object, the same name, or the same nonempty short fl...
Definition Arg.h:745
static constexpr char blankChar() noexcept
The char used as a place holder when SwitchArgs are combined.
Definition Arg.h:247
static constexpr char flagStartChar() noexcept
Definition Arg.h:256
virtual void addToList(std::list< Arg * > &argList) const
Adds this to the specified list of Args.
Definition Arg.h:815
static std::string nameStartString()
Definition Arg.h:275
static std::string ignoreNameString()
The name used to identify the ignore rest argument.
Definition Arg.h:280
virtual bool isRequired() const
Indicates whether the argument is required.
Definition Arg.h:761
virtual void setDescription(const std::string &desc)
Updates the argument description.
Definition Arg.h:335
The base class that manages the command line definition and passes along the parsing to the appropria...
The interface that any output object must implement.
virtual void failure(CmdLineInterface &c, ArgException &e)=0
Generates some sort of output for a failure.
Thrown from CmdLine when the arguments on the command line are not properly specified,...
Registration(const Registration &)=delete
Registration(CmdLine &cmd)
Definition CmdLine.h:584
void commit() noexcept
Definition CmdLine.h:613
Registration & operator=(const Registration &)=delete
The base class that manages the command line definition and passes along the parsing to the appropria...
Definition CmdLine.h:86
std::list< Arg * > _argList
The list of arguments that will be tested against the command line.
Definition CmdLine.h:92
void setMessageTranslator(const T &translator)
Sets an optional message translator callback.
Definition CmdLine.h:377
std::string getVersion() const override
Returns the version string.
Definition CmdLine.h:321
std::list< ArgGroup * > getArgGroups() override
Returns the list of ArgGroups.
Definition CmdLine.h:331
SwitchArg * _versionArg
Definition CmdLine.h:190
void reset() override
Allows the CmdLine object to be reused.
Definition CmdLine.h:771
SwitchArg * _ignoreArg
Built-in arguments whose descriptions may need refreshing when the translator changes.
Definition CmdLine.h:188
bool _emptyCombined(const std::string &s)
Checks whether a name/flag string matches entirely matches the Arg::blankChar.
Definition CmdLine.h:725
std::string getProgramName() const override
Returns the program name string.
Definition CmdLine.h:323
int _numRequired
The number of arguments that are required to be present on the command line.
Definition CmdLine.h:123
void addToArgList(Arg *a) override
Definition CmdLine.h:668
CmdLine & operator=(const CmdLine &rhs)=delete
std::string _version
The version to be displayed with the –version switch.
Definition CmdLine.h:116
bool _handleExceptions
Should CmdLine handle parsing exceptions internally?
Definition CmdLine.h:160
std::string _message
A message used to describe the program.
Definition CmdLine.h:111
StandaloneArgs _standaloneArgs
Definition CmdLine.h:94
void setOutput(CmdLineOutput *co) override
Definition CmdLine.h:765
CmdLineOutput * _output
Object that handles all output for the CmdLine.
Definition CmdLine.h:155
bool _registrationActive
Definition CmdLine.h:133
char _delimiter
The character that is used to separate the argument flag/name from the value.
Definition CmdLine.h:129
void ignoreUnmatched(const bool ignore)
Allows unmatched args to be ignored.
Definition CmdLine.h:778
CmdLine(const CmdLine &rhs)=delete
Prevent accidental copying.
std::unique_ptr< MessageTranslator > _messageTranslator
Definition CmdLine.h:182
std::list< ArgGroup * > _argGroups
Some args have set constraints on them (i.e., exactly or at most one must be specified.
Definition CmdLine.h:101
DeferDelete _deleteOnExit
Add pointers that should be deleted as part of cleanup when this object is destroyed.
Definition CmdLine.h:145
std::string _progName
The name of the program.
Definition CmdLine.h:106
bool hasHelpAndVersion() const override
Indicates whether or not the help and version switches were created automatically.
Definition CmdLine.h:339
std::list< Arg * > getArgList() const override
Definition CmdLine.h:328
bool hasExceptionHandling() const
Returns the current state of the internal exception handling.
Definition CmdLine.h:356
std::string translateMessage(const std::string &messageId, const std::string &fallback) const override
Translates a built-in message.
Definition CmdLine.h:385
void setExceptionHandling(const bool state)
Disables or enables CmdLine's internal parsing exception handling.
Definition CmdLine.h:767
StdOutput _defaultOutput
Default output handler if nothing is specified.
Definition CmdLine.h:150
std::string getMessage() const override
Returns the message string.
Definition CmdLine.h:338
SwitchArg * _helpArg
Definition CmdLine.h:189
char getDelimiter() const override
Returns the delimiter string.
Definition CmdLine.h:337
void xorAdd(Arg &a, Arg &b) override
Definition CmdLine.h:573
void missingArgsException(const std::list< ArgGroup * > &missing)
Throws an exception listing the missing args.
Definition CmdLine.h:731
~CmdLine() override=default
Deletes any resources allocated by a CmdLine object.
bool ignoreRest() override
Whether to ignore the rest.
Definition CmdLine.h:395
bool attachGroup(ArgGroup &group) override
Definition CmdLine.h:135
ArgContainer & add(Arg &a) override
Adds an argument to the list of arguments to be parsed.
Definition CmdLine.h:666
StandaloneArgs _autoArgs
Definition CmdLine.h:95
bool _hasOptionalUnlabeledArg
Definition CmdLine.h:132
void beginIgnoring() override
Begin ignoring arguments since the "--" argument was specified.
Definition CmdLine.h:394
void parse(int argc, const char *const *argv) override
Parses the command line.
Definition CmdLine.h:684
DeferDelete can be used by objects that need to allocate arbitrary other objects to live for the dura...
Definition DeferDelete.h:37
Thrown when TCLAP thinks the program should exit.
int getExitStatus() const noexcept
Implements a group of arguments where exactly one must be selected.
Definition ArgGroup.h:171
Thrown from Arg and CmdLine when an Arg is improperly specified, e.g.
bool showAsGroup() const override
If arguments in this group should show up as grouped in help.
Definition CmdLine.h:79
ArgContainer & add(Arg *arg) override
Add an argument to this arg group.
Definition CmdLine.h:65
A class that isolates any output from the CmdLine object so that it may be easily modified.
Definition StdOutput.h:49
A simple switch argument.
Definition SwitchArg.h:40
Definition Arg.h:54
std::string basename(std::string s)
std::string translate(const std::string &messageId, const std::string &fallback) const override
Definition CmdLine.h:175
MessageTranslatorImpl(const T &translator)
Definition CmdLine.h:174
Optional callback used to localize user-facing strings.
Definition CmdLine.h:165
virtual ~MessageTranslator()=default
virtual std::string translate(const std::string &messageId, const std::string &fallback) const =0