24 #ifndef TCLAP_ZSHCOMPLETIONOUTPUT_H 25 #define TCLAP_ZSHCOMPLETIONOUTPUT_H 88 std::map<std::string, std::string>
common;
93 :
common(std::map<std::string, std::string>()),
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 <<
121 "# " << progName <<
" version " << _cmd.
getVersion() << 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 <<
" '";
178 std::cout << count++;
183 std::cout << a->
getName() <<
':';
184 std::map<std::string, std::string>::iterator compArg =
common.find(a->
getName());
185 if ( compArg !=
common.end() )
187 std::cout << compArg->second;
191 std::cout <<
"_guard \"^-*\" " << a->
getName();
204 if (!desc.compare(0, 12,
"(required) "))
208 if (!desc.compare(0, 15,
"(OR required) "))
212 size_t len = desc.length();
213 if (len && desc.at(--len) ==
'.')
219 desc.replace(0, 1, 1, tolower(desc.at(0)));
222 std::cout <<
" \\" << std::endl <<
" '" << mutex;
230 std::cout <<
"'{" << flag <<
',' << name <<
"}'";
235 std::cout <<
'[' << desc <<
']';
239 std::string arg = a->
shortID();
241 size_t pos = arg.rfind(
" ...");
243 if (pos != std::string::npos) {
248 if ( arg.at(arg.length()-1) ==
']' )
249 arg.erase(arg.length()-1);
250 if ( arg.at(arg.length()-1) ==
']' )
252 arg.erase(arg.length()-1);
254 if ( arg.at(0) ==
'<' )
256 arg.erase(arg.length()-1);
259 size_t p = arg.find(
'|');
260 if ( p != std::string::npos )
264 arg.replace(p, 1, 1,
' ');
266 while ( (p = arg.find_first_of(
'|', p)) != std::string::npos );
268 std::cout <<
": :(" << arg <<
')';
272 std::cout <<
':' << arg;
273 std::map<std::string, std::string>::iterator compArg =
common.find(arg);
274 if ( compArg !=
common.end() )
276 std::cout <<
':' << compArg->second;
287 std::vector< std::vector<Arg*> > xorList = xorHandler.
getXorList();
300 for (
int i = 0;
static_cast<unsigned int>(i) < xorList.size(); i++ )
303 it != xorList[i].end();
309 iu != xorList[i].end();
312 bool notCur = (*iu) != a;
313 bool hasFlag = !(*iu)->
getFlag().empty();
314 if ( iu != xorList[i].begin() && (notCur || hasFlag) )
317 list << (*iu)->flagStartChar() << (*iu)->getFlag() <<
' ';
318 if ( notCur || hasFlag )
319 list << (*iu)->nameStartString() << (*iu)->getName();
A virtual base class that defines the essential data for all arguments.
A simple class that defines and argument exception.
virtual std::string & getProgramName()=0
Returns the program name string.
static char flagStartChar()
virtual std::list< Arg * > & getArgList()=0
Returns the argList.
virtual char getDelimiter()=0
Returns the delimiter string.
void quoteSpecialChars(std::string &s)
const std::vector< std::vector< Arg * > > & getXorList() const
virtual bool isRequired() const
Indicates whether the argument is required.
virtual std::string & getVersion()=0
Returns the version string.
virtual void version(CmdLineInterface &c)
Prints the version to stdout.
void printOption(Arg *it, std::string mutex)
void basename(std::string &s)
virtual XorHandler & getXorHandler()=0
Returns the XorHandler.
static const std::string nameStartString()
std::vector< Arg * >::const_iterator ArgVectorIterator
Typedef of an Arg vector iterator.
virtual void usage(CmdLineInterface &c)
Prints the usage to stdout.
const std::string & getName() const
Returns the argument name.
virtual std::string shortID(const std::string &valueId="val") const
Returns a short ID for the usage.
The base class that manages the command line definition and passes along the parsing to the appropria...
bool isValueRequired() const
Indicates whether a value must be specified for argument.
virtual bool acceptsMultipleValues()
Use by output classes to determine whether an Arg accepts multiple values.
std::ostringstream ostringstream
std::string getDescription() const
Returns the argument description.
const std::string & getFlag() const
Returns the argument flag.
std::list< Arg * >::const_iterator ArgListIterator
Typedef of an Arg list iterator.
std::map< std::string, std::string > common
std::string getMutexList(CmdLineInterface &_cmd, Arg *a)
This class handles lists of Arg's that are to be XOR'd on the command line.
virtual void failure(CmdLineInterface &c, ArgException &e)
Prints (to stderr) an error message, short usage Can be overridden to produce alternative behavior...
const char * what() const
Returns the arg id and error text.
The interface that any output object must implement.
A class that generates a Zsh completion function as output from the usage() method for the given CmdL...