66 {
67
68 std::cout << std::endl << "USAGE: " << std::endl << std::endl;
69 _shortUsage(_cmd, std::cout);
70 std::cout << std::endl
71 << std::endl
72 << "Where: " << std::endl
73 << std::endl;
74
75 std::string const message = _cmd.getMessage();
76 std::list<TCLAP::ArgGroup*> argSets = _cmd.getArgGroups();
77
78 std::list<TCLAP::Arg*> unlabelled;
79 for (std::list<TCLAP::ArgGroup*>::iterator sit = argSets.begin();
80 sit != argSets.end();
81 ++sit)
82 {
83 TCLAP::ArgGroup& argGroup = **sit;
84
85 int const visible = CountVisibleArgs(argGroup);
86 bool const exclusive = visible > 1 && argGroup.isExclusive();
87 bool const forceRequired = visible == 1 && argGroup.isRequired();
88 if (exclusive)
89 {
90 spacePrint(std::cout,
91 argGroup.isRequired() ? "One of:" : "Either of:", 75,
92 3, 0);
93 }
94
95 for (TCLAP::ArgGroup::iterator it = argGroup.begin();
96 it != argGroup.end();
97 ++it)
98 {
99 TCLAP::Arg& arg = **it;
100
101 if (!arg.visibleInHelp())
102 {
103 continue;
104 }
105
106 if (!arg.hasLabel())
107 {
108 unlabelled.push_back(&arg);
109 continue;
110 }
111
112
113 std::string const shortID = arg.shortID();
114 std::smatch match;
115 bool const required = arg.isRequired() || forceRequired;
116 std::stringstream ss;
117 if (std::regex_search(shortID, match, std::regex("<([^>]+)>")))
118 {
119 std::string const identifier = match[1];
120
121 ss << identifier;
129 ss << ": ";
130 }
131 ss << arg.getDescription(required);
132
133 if (exclusive)
134 {
135 spacePrint(std::cout, arg.longID(), 75, 6, 3);
136 spacePrint(std::cout, ss.str(), 75, 8, 0);
137 }
138 else
139 {
140 spacePrint(std::cout, arg.longID(), 75, 3, 3);
141 spacePrint(std::cout, ss.str(), 75, 5, 0);
142 }
143 std::cout << '\n';
144 }
145 }
146
147 for (TCLAP::ArgListIterator it = unlabelled.begin();
148 it != unlabelled.end();
149 ++it)
150 {
151 const TCLAP::Arg& arg = **it;
152 spacePrint(std::cout, arg.longID(), 75, 3, 3);
153 spacePrint(std::cout, arg.getDescription(), 75, 5, 0);
154 std::cout << '\n';
155 }
156
157 if (!message.empty())
158 {
159 spacePrint(std::cout, message, 75, 3, 0);
160 }
161
162 std::cout.flush();
163 }
void tryPrintValue(TCLAP::Arg *arg, std::ostream &os, bool required)