Changeset 3255 for code/branches/core4/src/core/CommandLine.cc
- Timestamp:
- Jun 29, 2009, 11:59:29 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/core4/src/core/CommandLine.cc
r3250 r3255 29 29 #include "CommandLine.h" 30 30 31 #include <sstream> 31 32 #include <boost/filesystem.hpp> 32 33 … … 231 232 { 232 233 COUT(0) << "Could not parse command line (including additional files): " << ex.what() << std::endl; 233 COUT(0) << "Usage:" << std::endl << "orxonox " <<CommandLine::getUsageInformation() << std::endl;234 COUT(0) << CommandLine::getUsageInformation() << std::endl; 234 235 throw GeneralException(""); 235 236 } … … 272 273 std::string CommandLine::getUsageInformation() 273 274 { 274 CommandLine* inst = &_getInstance(); 275 std::string infoStr; 276 for (std::map<std::string, CommandLineArgument*>::const_iterator it = inst->cmdLineArgs_.begin(); 277 it != inst->cmdLineArgs_.end(); ++it) 278 { 279 infoStr += "[--" + it->second->getName() + " " + it->second->getInformation() + "] "; 280 } 281 return infoStr; 275 CommandLine& inst = _getInstance(); 276 std::ostringstream infoStr; 277 278 // determine maximum name size 279 size_t maxNameSize = 0; 280 for (std::map<std::string, CommandLineArgument*>::const_iterator it = inst.cmdLineArgs_.begin(); 281 it != inst.cmdLineArgs_.end(); ++it) 282 { 283 maxNameSize = std::max(it->second->getName().size(), maxNameSize); 284 } 285 286 infoStr << "Usage: orxonox [options]" << std::endl; 287 infoStr << "Available options:" << std::endl; 288 289 for (std::map<std::string, CommandLineArgument*>::const_iterator it = inst.cmdLineArgs_.begin(); 290 it != inst.cmdLineArgs_.end(); ++it) 291 { 292 if (it->second->getShortcut() != "") 293 infoStr << " [-" << it->second->getShortcut() << "] "; 294 else 295 infoStr << " "; 296 infoStr << "--" << it->second->getName() << " "; 297 if (it->second->getValue().getType() != MT_bool) 298 infoStr << "ARG "; 299 else 300 infoStr << " "; 301 // fill with the necessary amount of blanks 302 infoStr << std::string(maxNameSize - it->second->getName().size(), ' '); 303 infoStr << ": " << it->second->getInformation(); 304 infoStr << std::endl; 305 } 306 return infoStr.str(); 282 307 } 283 308
Note: See TracChangeset
for help on using the changeset viewer.