inline std::unique_ptr<Command> get_command(const std::string& name) { for (auto& command: all_commands()) { if (command.name == name) { return command.create(); } } throw CFilesError("Can not find the subcommand '" + name + "'"); }
std::string list_commands(const ARG_LIST &args) { std::string ret; for (auto str : all_commands()) { ret += (str + "\n"); } return ret; }
void Help::list_commands() const { const size_t command_width = 10; std::cout << "Available subcommands:" << std::endl; for (auto& command: all_commands()) { auto name = command.name; auto description = command.create()->description(); std::cout << " " << name << std::string(command_width - name.size(), ' '); std::cout << description << std::endl; } }