Give a list of available commands or describe a specific command. */
| 317 | |
| 318 | /** Give a list of available commands or describe a specific command. */ |
| 319 | static CLIStatus showHelp(int argc, char** argv, ostream& os) |
| 320 | { |
| 321 | if (argc==2) { |
| 322 | os << argv[1] << " " << gParser.help(argv[1]) << endl; |
| 323 | return SUCCESS; |
| 324 | } |
| 325 | if (argc!=1) return BAD_NUM_ARGS; |
| 326 | ParseTable::const_iterator cp = gParser.begin(); |
| 327 | os << endl << "Type \"help\" followed by the command name for help on that command." << endl << endl; |
| 328 | int c=0; |
| 329 | const int cols = 3; |
| 330 | while (cp != gParser.end()) { |
| 331 | const string& wd = cp->first; |
| 332 | os << wd << '\t'; |
| 333 | if (wd.size()<8) os << '\t'; |
| 334 | ++cp; |
| 335 | c++; |
| 336 | if (c%cols==0) os << endl; |
| 337 | } |
| 338 | if (c%cols!=0) os << endl; |
| 339 | return SUCCESS; |
| 340 | } |
| 341 | |
| 342 | |
| 343 |