12 #include <tclap/Arg.h>
13 #include <tclap/CmdLineInterface.h>
14 #include <tclap/CmdLineOutput.h>
15 #include <tclap/StdOutput.h>
16 #include <tclap/XorHandler.h>
38 virtual void usage(TCLAP::CmdLineInterface& cmd_);
46 virtual void failure(TCLAP::CmdLineInterface& cmd_, TCLAP::ArgException& e);
54 void shortUsage_(TCLAP::CmdLineInterface& cmd_, std::ostream& os)
const;
62 void longUsage_(TCLAP::CmdLineInterface& cmd_, std::ostream& os)
const;
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;
79 TCLAP::ArgException& e)
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);
107 std::ostream& os)
const
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);
150 std::ostream& os)
const
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);
virtual void usage(TCLAP::CmdLineInterface &cmd_)
void longUsage_(TCLAP::CmdLineInterface &cmd_, std::ostream &os) const
virtual void failure(TCLAP::CmdLineInterface &cmd_, TCLAP::ArgException &e)
void shortUsage_(TCLAP::CmdLineInterface &cmd_, std::ostream &os) const