method used by help_message()
| 318 | |
| 319 | // method used by help_message() |
| 320 | void |
| 321 | ArgParser::Command::output_command(std::ostream &out, std::string const &prefix) const |
| 322 | { |
| 323 | if (_name != parser_program_name) { |
| 324 | // a nicely formatted way to output command usage |
| 325 | std::string msg = prefix + _name; |
| 326 | // nicely formatted output |
| 327 | if (!_description.empty()) { |
| 328 | if (INDENT_ONE - static_cast<int>(msg.size()) < 0) { |
| 329 | // if the command msg is too long |
| 330 | std::cout << msg << "\n" << std::string(INDENT_ONE, ' ') << _description << std::endl; |
| 331 | } else { |
| 332 | std::cout << msg << std::string(INDENT_ONE - msg.size(), ' ') << _description << std::endl; |
| 333 | } |
| 334 | } |
| 335 | } |
| 336 | // recursive call |
| 337 | for (const auto &it : _subcommand_list) { |
| 338 | it.second.output_command(out, " " + prefix); |
| 339 | } |
| 340 | } |
| 341 | |
| 342 | // a nicely formatted way to output option message for help. |
| 343 | void |