没有任何数据可供显示
开源项目社区 | 当前位置 : |
|
www.trustie.net/open_source_projects | 主页 > 开源项目社区 > clipo |
clipo
|
0 | 0 | 12 |
贡献者 | 讨论 | 代码提交 |
Clipo : Command Line Interpreter library based on the boost Program Option libraryThe idea is to build on top of the program_option library developed by Vladimir Prus (http://www.boost.org/doc/html/program_options.html) an easy to implement command line interpreter library.
Examplenamespace po = boost::program_options;
void handler(const std::vector ¶meters)
{
for (std::vector::const_iterator it = parameters.begin();
it != parameters.end();
++it)
std::cout << *it << std::endl;
}
void exit_(unsigned int code = 0)
{
exit(code);
}
int main(int argc, char **argv)
{
boost::cli::commands_description desc;
desc.add_options()
("handler", po::value< std::vector >()->notifier(&handler)->multitoken())
("exit", po::value< unsigned int >()->notifier(&exit_))
;
boost::cli::command_line_interpreter cli(desc, ">");
cli.interpret(std::cin);
}output:
>handler
error: required parameter is missing in 'handler'
>handler 1 2 3
1
2
3
>toto
error: unknown option toto
>exit 0
Press any key to continue . . .