24#ifndef TCLAP_ZSHCOMPLETIONOUTPUT_H
25#define TCLAP_ZSHCOMPLETIONOUTPUT_H
88 std::map<std::string, std::string>
common;
97 common[
"hostname"] =
"_hosts";
99 common[
"filename"] =
"_files";
100 common[
"user"] =
"_users";
101 common[
"username"] =
"_users";
102 common[
"directory"] =
"_directories";
103 common[
"path"] =
"_directories";
120 std::cout <<
"#compdef " <<
progName << std::endl << std::endl <<
126 if ( (*it)->shortID().at(0) ==
'<' )
128 else if ( (*it)->getFlag() !=
"-" )
132 std::cout << std::endl;
138 static_cast<void>(_cmd);
139 std::cout <<
e.what() << std::endl;
144 size_t idx =
s.find_last_of(
':');
145 while (
idx != std::string::npos )
147 s.insert(
idx, 1,
'\\');
148 idx =
s.find_last_of(
':',
idx);
150 idx =
s.find_last_of(
'\'');
151 while (
idx != std::string::npos )
153 s.insert(
idx,
"'\\'");
155 idx = std::string::npos;
157 idx =
s.find_last_of(
'\'', --
idx);
163 size_t p =
s.find_last_of(
'/');
164 if (
p != std::string::npos )
172 static int count = 1;
174 std::cout <<
" \\" << std::endl <<
" '";
175 if (
a->acceptsMultipleValues() )
178 std::cout <<
count++;
180 if ( !
a->isRequired() )
183 std::cout <<
a->getName() <<
':';
184 std::map<std::string, std::string>::iterator
compArg =
common.find(
a->getName());
191 std::cout <<
"_guard \"^-*\" " <<
a->getName();
198 std::string
flag =
a->flagStartChar() +
a->getFlag();
199 std::string
name =
a->nameStartString() +
a->getName();
200 std::string
desc =
a->getDescription();
204 if (!
desc.compare(0, 12,
"(required) "))
208 if (!
desc.compare(0, 15,
"(OR required) "))
222 std::cout <<
" \\" << std::endl <<
" '" <<
mutex;
224 if (
a->getFlag().empty() )
230 std::cout <<
"'{" <<
flag <<
',' <<
name <<
"}'";
235 std::cout <<
'[' <<
desc <<
']';
237 if (
a->isValueRequired() )
239 std::string
arg =
a->shortID();
241 size_t pos =
arg.rfind(
" ... ");
242 if (
pos != std::string::npos) {
247 if (
arg.at(
arg.length()-1) ==
']' )
248 arg.erase(
arg.length()-1);
249 if (
arg.at(
arg.length()-1) ==
']' )
251 arg.erase(
arg.length()-1);
253 if (
arg.at(0) ==
'<' )
255 arg.erase(
arg.length()-1);
258 size_t p =
arg.find(
'|');
259 if (
p != std::string::npos )
263 arg.replace(
p, 1, 1,
' ');
265 while ( (
p =
arg.find_first_of(
'|',
p)) != std::string::npos );
267 std::cout <<
": :(" <<
arg <<
')';
271 std::cout <<
':' <<
arg;
275 std::cout <<
':' <<
compArg->second;
288 if (
a->getName() ==
"help" ||
a->getName() ==
"version")
294 if (
a->acceptsMultipleValues() )
299 for (
int i = 0;
static_cast<unsigned int>(
i) <
xorList.size();
i++ )
312 bool hasFlag = !(*iu)->getFlag().empty();
316 list << (*iu)->flagStartChar() << (*iu)->getFlag() <<
' ';
318 list << (*iu)->nameStartString() << (*iu)->getName();
326 if (!
a->getFlag().empty()) {
327 list <<
"(" <<
a->flagStartChar() <<
a->getFlag() <<
' ' <<
328 a->nameStartString() <<
a->getName() <<
')';
A simple class that defines and argument exception.
A virtual base class that defines the essential data for all arguments.
The base class that manages the command line definition and passes along the parsing to the appropria...
virtual XorHandler & getXorHandler()=0
Returns the XorHandler.
virtual std::list< Arg * > & getArgList()=0
Returns the argList.
virtual std::string & getProgramName()=0
Returns the program name string.
virtual char getDelimiter()=0
Returns the delimiter string.
virtual std::string & getVersion()=0
Returns the version string.
The interface that any output object must implement.
This class handles lists of Arg's that are to be XOR'd on the command line.
std::vector< std::vector< Arg * > > & getXorList()
A class that generates a Zsh completion function as output from the usage() method for the given CmdL...
void printOption(Arg *it, std::string mutex)
virtual void usage(CmdLineInterface &c)
Prints the usage to stdout.
void basename(std::string &s)
virtual void version(CmdLineInterface &c)
Prints the version to stdout.
std::map< std::string, std::string > common
void quoteSpecialChars(std::string &s)
virtual void failure(CmdLineInterface &c, ArgException &e)
Prints (to stderr) an error message, short usage Can be overridden to produce alternative behavior.
std::string getMutexList(CmdLineInterface &_cmd, Arg *a)
std::vector< Arg * >::iterator ArgVectorIterator
Typedef of an Arg vector iterator.
std::list< Arg * >::iterator ArgListIterator
Typedef of an Arg list iterator.
std::ostringstream ostringstream