59 lines
1.4 KiB
C++
59 lines
1.4 KiB
C++
#include <iostream>
|
|
#include <boost/program_options.hpp>
|
|
|
|
int
|
|
main (int argc, char** argv)
|
|
{
|
|
namespace po = boost::program_options;
|
|
|
|
// Register all possible options
|
|
po::options_description desc("Allowed options");
|
|
desc.add_options()
|
|
("help,h", "produce help message")
|
|
("filter,f", po::value<std::vector<std::string> > (), "apply a filter")
|
|
("input-file,i", po::value<std::vector<std::string> > (), "file to treat")
|
|
;
|
|
|
|
// Handle ./prpa file.avi instead of ./prpa --input-file=file.avi
|
|
po::positional_options_description p;
|
|
p.add("input-file", -1);
|
|
|
|
// Read command line
|
|
po::variables_map vm;
|
|
try
|
|
{
|
|
po::store(po::command_line_parser(argc, argv).
|
|
options(desc).positional(p).run(), vm);
|
|
}
|
|
catch (po::invalid_command_line_syntax e)
|
|
{
|
|
std::cerr << argv[0] << ": " << e.what() << std::endl;
|
|
return 1;
|
|
}
|
|
po::notify(vm);
|
|
|
|
// Handle -h and --help
|
|
if (argc <= 1 || vm.count("help"))
|
|
{
|
|
std::cout << desc << "\n";
|
|
return 1;
|
|
}
|
|
|
|
// GO!
|
|
std::cout << "Given filters: ";
|
|
if (vm.count("filter"))
|
|
std::cout << vm["filter"].as<std::vector<std::string> > ().size()
|
|
<< std::endl;
|
|
else
|
|
std::cout << 0 << std::endl;
|
|
|
|
std::cout << "Given files: ";
|
|
if (vm.count("input-file"))
|
|
std::cout << vm["input-file"].as<std::vector<std::string> > ().size()
|
|
<< std::endl;
|
|
else
|
|
std::cout << 0 << std::endl;
|
|
|
|
return 0;
|
|
}
|