OVERKILL을 말하기 전에, 나는 상관하지 않는다.'-'with boost.program_options
Boost.program_options가 필요한 cat
옵션 -
을 처리하도록하려면 어떻게해야합니까? ,
가 나는 그것이 위치 인수로 -
를보고 싶어 '-'
알 수없는 옵션 :
나는
cat - - -
를 실행할 때 예외가 발생// visible po::options_description options("Options"); options.add_options()("-u", po::value<bool>(), "Write bytes from the input file to the standard output without delay as each is read."); po::positional_options_description file_options; file_options.add("file", -1); po::variables_map vm; po::store(po::command_line_parser(argc, argv).options(options).positional(file_options).run(), vm); po::notify(vm); bool immediate = false; if(vm.count("-u")) immediate = true; if(vm.count("file")) support::print(vm["file"].as<vector<string>>());
이 전체 파일 목록에서 올바른 순서로 필요합니다. 내가 어떻게 이걸 얻을 수 있니?
UPDATE 나는 반 수정이 있습니다. 나는
po::options_description options("Options"); options.add_options()("-u", po::value<bool>(), "Write bytes from the input file to the standard output without delay as each is read.") ("file", po::value< vector<string> >(), "input file"); po::positional_options_description file_options; file_options.add("file", -1);
문제는 나는 단지 2를 얻을 것입니다
을 필요로하는 세 가지-
때 출력 인수 : 지원 :: 인쇄가 잘 벡터 물건을 처리if(vm.count("file")) support::print(vm["file"].as<vector<string>>());
.
Boost.PO는 자체적 인 (제한적인 종류의) 옵션 구문을 가지고 있습니다. Boost.PO를 원하는 구문에 사용할 수 있습니다. – Abyx
@Oli : 완료. 감사. – rubenvb