https://blog.csdn.net/jkhere/article/details/8674019

https://sophia0130.github.io/2018/05/08/CommandLineParse%E7%B1%BB/

https://blog.csdn.net/ylf_2278880589/article/details/80811304

Java命令行选项解析之Commons-CLI & Args4J & JCommander

这个类的出现主要是方便用户在命令行使用过程中减少工作量,可以在程序文件中直接指定命令行中的参数指令,方便了调试。

1. C++ 例子:

 

#include "opencv2/video/tracking.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/highgui/highgui.hpp"
 
#include <iostream>
#include <ctype.h>
#include <string>
 
using namespace cv;
using namespace std;
 
const char* keys =
{
    "{ c | camera | 0 | use camera or not}"
    "{ fn | filename |xxxx.avi | movie file}"
    "{ t | test | test string | good day!}"
};
 
 
int main(int argc, const char** argv )
{
 
    CommandLineParser parser(argc, argv, keys);
    
    bool useCamera = parser.get<bool>("c");//括号里写成“camera”也可以
    string file = parser.get<string>("fn");
    string third = parser.get<string>("t");
 
    //打印输出
    cout<<useCamera<<endl;
    cout<<file<<endl;
    cout<<third<<endl;
    cout<<endl;
    parser.printParams();//CommandLineParser的成员函数,打印全部参数,还有其他成员函数,如:has(),getString()等
    return 0;
}
View Code

相关文章:

  • 2021-12-10
  • 2021-09-13
  • 2022-12-23
  • 2020-06-12
  • 2022-01-29
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-12-23
  • 2021-08-01
  • 2022-12-23
  • 2021-08-03
  • 2022-12-23
  • 2022-02-15
  • 2022-12-23
相关资源
相似解决方案