Added the usage report to the examples for when no arguments are passed

to the examples.
This commit is contained in:
Robert Osfield
2003-04-06 21:32:44 +00:00
parent 908164d58a
commit 49a28660dc
40 changed files with 166 additions and 72 deletions

View File

@@ -145,12 +145,12 @@ void ApplicationUsage::write(std::ostream& output, const ApplicationUsage::Usage
output << str << std::endl;
}
void ApplicationUsage::write(std::ostream& output,unsigned int widthOfOutput)
void ApplicationUsage::write(std::ostream& output, unsigned int type, unsigned int widthOfOutput)
{
output << "Usage: "<<getCommandLineUsage()<<std::endl;
bool needspace = false;
if (!getCommandLineOptions().empty())
if ((type&COMMAND_LINE_OPTION) && !getCommandLineOptions().empty())
{
if (needspace) output << std::endl;
output << "Options:"<<std::endl;
@@ -158,7 +158,7 @@ void ApplicationUsage::write(std::ostream& output,unsigned int widthOfOutput)
needspace = true;
}
if (!getEnvironmentalVariables().empty())
if ((type&ENVIRONMENTAL_VARIABLE) && !getEnvironmentalVariables().empty())
{
if (needspace) output << std::endl;
output << "Environmental Variables:"<<std::endl;
@@ -166,7 +166,7 @@ void ApplicationUsage::write(std::ostream& output,unsigned int widthOfOutput)
needspace = true;
}
if (!getKeyboardMouseBindings().empty())
if ((type&KEYBOARD_MOUSE_BINDING) && !getKeyboardMouseBindings().empty())
{
if (needspace) output << std::endl;
output << "Keyboard and Mouse Bindings:"<<std::endl;

View File

@@ -14,7 +14,7 @@ ArgumentParser::ArgumentParser(int* argc,char **argv):
{
}
std::string ArgumentParser::getProgramName() const
std::string ArgumentParser::getApplicationName() const
{
if (_argc>0) return std::string(_argv[0]);
return "";
@@ -314,7 +314,7 @@ void ArgumentParser::reportRemainingOptionsAsUnrecognized(ErrorSeverity severity
// if an option and havn't been previous querried for report as unrecognized.
if (isOption(pos) && options.find(_argv[pos])==options.end())
{
reportError(getProgramName() +": unrceognized option "+_argv[pos],severity);
reportError(getApplicationName() +": unrceognized option "+_argv[pos],severity);
}
}
}
@@ -326,7 +326,7 @@ void ArgumentParser::writeErrorMessages(std::ostream& output,ErrorSeverity sever
{
if (itr->second>=severity)
{
output<< getProgramName() << ": " << itr->first << std::endl;
output<< getApplicationName() << ": " << itr->first << std::endl;
}
}
}