You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
841 B

2 years ago
  1. # 使用说明
  2. ## 快速上手
  3. ### 例子一
  4. ```c++
  5. #include "zclipp/include/clipp.h"
  6. using namespace clipp;
  7. //
  8. // 下面代码实现解析如下命令,且两个参数都是必要参数,如果参数未指定,则解析失败
  9. // ./app.out --device_id=XXXXXXX --host_server_ip=192.168.1.1
  10. //
  11. //
  12. void main(){
  13. string g_host_server_ip;
  14. string g_device_id;
  15. auto cli = ( //
  16. (required("--host_server_ip") & value("host server ip", g_host_server_ip)).doc("chicken_farm_system host ip"), //
  17. (required("--device_id") & value("device_id", g_device_id)).doc("device_id") //
  18. );
  19. if (!parse(argc, argv, cli)) {
  20. cout << make_man_page(cli, argv[0]);
  21. return;
  22. }
  23. }
  24. ```