23 #ifndef TCLAP_ZSHCOMPLETIONOUTPUT_H
24 #define TCLAP_ZSHCOMPLETIONOUTPUT_H
82 std::map<std::string, std::string>
common;
89 common[
"hostname"] =
"_hosts";
91 common[
"filename"] =
"_files";
93 common[
"username"] =
"_users";
94 common[
"directory"] =
"_directories";
95 common[
"path"] =
"_directories";
112 std::cout <<
"#compdef " << progName << std::endl << std::endl <<
113 "# " << progName <<
" version " << _cmd.
getVersion() << std::endl << std::endl <<
118 if ( (*it)->shortID().at(0) ==
'<' )
120 else if ( (*it)->getFlag() !=
"-" )
124 std::cout << std::endl;
130 static_cast<void>(_cmd);
131 std::cout << e.
what() << std::endl;
136 size_t idx = s.find_last_of(
':');
137 while ( idx != std::string::npos )
139 s.insert(idx, 1,
'\\');
140 idx = s.find_last_of(
':', idx);
142 idx = s.find_last_of(
'\'');
143 while ( idx != std::string::npos )
145 s.insert(idx,
"'\\'");
147 idx = std::string::npos;
149 idx = s.find_last_of(
'\'', --idx);
155 size_t p = s.find_last_of(
'/');
156 if ( p != std::string::npos )
164 static int count = 1;
166 std::cout <<
" \\" << std::endl <<
" '";
170 std::cout << count++;
175 std::cout << a->
getName() <<
':';
176 std::map<std::string, std::string>::iterator compArg =
common.find(a->
getName());
177 if ( compArg !=
common.end() )
179 std::cout << compArg->second;
183 std::cout <<
"_guard \"^-*\" " << a->
getName();
196 if (!desc.compare(0, 12,
"(required) "))
200 if (!desc.compare(0, 15,
"(OR required) "))
204 size_t len = desc.length();
205 if (len && desc.at(--len) ==
'.')
211 desc.replace(0, 1, 1, tolower(desc.at(0)));
214 std::cout <<
" \\" << std::endl <<
" '" << mutex;
222 std::cout <<
"'{" << flag <<
',' << name <<
"}'";
227 std::cout <<
'[' << desc <<
']';
231 std::string arg = a->
shortID();
233 if ( arg.at(arg.length()-1) ==
']' )
234 arg.erase(arg.length()-1);
235 if ( arg.at(arg.length()-1) ==
']' )
237 arg.erase(arg.length()-1);
239 if ( arg.at(0) ==
'<' )
241 arg.erase(arg.length()-1);
244 size_t p = arg.find(
'|');
245 if ( p != std::string::npos )
249 arg.replace(p, 1, 1,
' ');
251 while ( (p = arg.find_first_of(
'|', p)) != std::string::npos );
253 std::cout <<
": :(" << arg <<
')';
257 std::cout <<
':' << arg;
258 std::map<std::string, std::string>::iterator compArg =
common.find(arg);
259 if ( compArg !=
common.end() )
261 std::cout <<
':' << compArg->second;
272 std::vector< std::vector<Arg*> > xorList = xorHandler.
getXorList();
279 std::ostringstream list;
285 for (
int i = 0;
static_cast<unsigned int>(i) < xorList.size(); i++ )
288 it != xorList[i].end();
294 iu != xorList[i].end();
297 bool notCur = (*iu) != a;
298 bool hasFlag = !(*iu)->
getFlag().empty();
299 if ( iu != xorList[i].begin() && (notCur || hasFlag) )
302 list << (*iu)->flagStartChar() << (*iu)->getFlag() <<
' ';
303 if ( notCur || hasFlag )
304 list << (*iu)->nameStartString() << (*iu)->getName();