示例#1
0
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 + "'");
}
示例#2
0
std::string list_commands(const ARG_LIST &args) {
	std::string ret;
	for (auto str : all_commands()) {
		ret += (str + "\n");
	}

	return ret;
}
示例#3
0
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;
    }
}