TCLAP standard output modified as follows
- Print arguments in the order of added to Command object
Definition at line 30 of file TCLAPCustomOutput.h.
#include <TCLAPCustomOutput.h>
|
virtual void | usage (TCLAP::CmdLineInterface &cmd_) |
|
virtual void | failure (TCLAP::CmdLineInterface &cmd_, TCLAP::ArgException &e) |
|
|
void | shortUsage_ (TCLAP::CmdLineInterface &cmd_, std::ostream &os) const |
|
void | longUsage_ (TCLAP::CmdLineInterface &cmd_, std::ostream &os) const |
|
◆ failure()
void BaseLib::TCLAPCustomOutput::failure |
( |
TCLAP::CmdLineInterface & |
cmd_, |
|
|
TCLAP::ArgException & |
e |
|
) |
| |
|
inlinevirtual |
Prints (to stderr) an error message, short usage Can be overridden to produce alternative behavior.
- Parameters
-
cmd_ | - The CmdLine object the output is generated for. |
e | - The ArgException that caused the failure. |
Definition at line 78 of file TCLAPCustomOutput.h.
81 std::string progName = cmd_.getProgramName();
83 std::cerr <<
"PARSE ERROR: " << e.argId() << std::endl
84 <<
" " << e.error() << std::endl
87 if (cmd_.hasHelpAndVersion())
89 std::cerr <<
"Brief USAGE: " << std::endl;
93 std::cerr << std::endl
94 <<
"For complete USAGE and HELP type: " << std::endl
95 <<
" " << progName <<
" --help" << std::endl
103 throw TCLAP::ExitException(1);
virtual void usage(TCLAP::CmdLineInterface &cmd_)
void shortUsage_(TCLAP::CmdLineInterface &cmd_, std::ostream &os) const
References shortUsage_(), and usage().
◆ longUsage_()
void BaseLib::TCLAPCustomOutput::longUsage_ |
( |
TCLAP::CmdLineInterface & |
cmd_, |
|
|
std::ostream & |
os |
|
) |
| const |
|
inlineprotected |
Writes a longer usage message with long and short args, provides descriptions and prints message.
- Parameters
-
cmd_ | - The CmdLine object the output is generated for. |
os | - The stream to write the message to. |
Definition at line 149 of file TCLAPCustomOutput.h.
152 std::list<TCLAP::Arg*> argList = cmd_.getArgList();
153 std::string message = cmd_.getMessage();
154 TCLAP::XorHandler xorHandler = cmd_.getXorHandler();
155 std::vector<std::vector<TCLAP::Arg*>> xorList = xorHandler.getXorList();
158 for (
int i = 0;
static_cast<unsigned int>(i) < xorList.size(); i++)
160 for (TCLAP::ArgVectorIterator it = xorList[i].begin();
161 it != xorList[i].end();
164 this->spacePrint(os, (*it)->longID(), 75, 3, 3);
165 spacePrint(os, (*it)->getDescription(), 75, 5, 0);
167 if (it + 1 != xorList[i].end())
169 spacePrint(os,
"-- OR --", 75, 9, 0);
172 os << std::endl << std::endl;
176 for (
auto it = argList.rbegin(); it != argList.rend(); it++)
178 if (!xorHandler.contains((*it)))
180 spacePrint(os, (*it)->longID(), 75, 3, 3);
181 spacePrint(os, (*it)->getDescription(), 75, 5, 0);
188 spacePrint(os, message, 75, 3, 0);
Referenced by usage().
◆ shortUsage_()
void BaseLib::TCLAPCustomOutput::shortUsage_ |
( |
TCLAP::CmdLineInterface & |
cmd_, |
|
|
std::ostream & |
os |
|
) |
| const |
|
inlineprotected |
Writes a brief usage message with short args.
- Parameters
-
cmd_ | - The CmdLine object the output is generated for. |
os | - The stream to write the message to. |
Definition at line 106 of file TCLAPCustomOutput.h.
109 std::list<TCLAP::Arg*> argList = cmd_.getArgList();
110 std::string progName = cmd_.getProgramName();
111 TCLAP::XorHandler xorHandler = cmd_.getXorHandler();
112 std::vector<std::vector<TCLAP::Arg*>> xorList = xorHandler.getXorList();
114 std::string s = progName +
" ";
117 for (
int i = 0;
static_cast<unsigned int>(i) < xorList.size(); i++)
120 for (TCLAP::ArgVectorIterator it = xorList[i].begin();
121 it != xorList[i].end();
124 s += (*it)->shortID() +
"|";
127 s[s.length() - 1] =
'}';
131 for (
auto it = argList.rbegin(); it != argList.rend(); ++it)
133 if (!xorHandler.contains((*it)))
135 s +=
" " + (*it)->shortID();
140 int secondLineOffset =
static_cast<int>(progName.length()) + 2;
141 if (secondLineOffset > 75 / 2)
143 secondLineOffset =
static_cast<int>(75 / 2);
146 spacePrint(os, s, 75, 3, secondLineOffset);
Referenced by failure(), and usage().
◆ usage()
void BaseLib::TCLAPCustomOutput::usage |
( |
TCLAP::CmdLineInterface & |
cmd_ | ) |
|
|
inlinevirtual |
Prints the usage to stdout. Can be overridden to produce alternative behavior.
- Parameters
-
cmd_ | - The CmdLine object the output is generated for. |
Definition at line 65 of file TCLAPCustomOutput.h.
67 std::cout << std::endl <<
"USAGE: " << std::endl << std::endl;
71 std::cout << std::endl << std::endl <<
"Where: " << std::endl << std::endl;
75 std::cout << std::endl;
void longUsage_(TCLAP::CmdLineInterface &cmd_, std::ostream &os) const
References longUsage_(), and shortUsage_().
Referenced by failure().
The documentation for this class was generated from the following file: