Revision e0b7f8b9
Added by David Sorber over 9 years ago
| software/photo_compress_archiver/main.cc | ||
|---|---|---|
|
}
|
||
|
|
||
|
header();
|
||
|
std::cout << "USAGE: " << app_name << " [-hkd] <file path>\n\n";
|
||
|
std::cout << "USAGE: " << app_name << " [-hkd] [-f <filter regex>] <file path>\n\n";
|
||
|
std::cout << "Positional arguments:\n";
|
||
|
std::cout << " <file path> path in which to recursively look "
|
||
|
<< "for input files\n\n";
|
||
| ... | ... | |
|
std::cout << " -h [ --help ] display this help message\n";
|
||
|
std::cout << " -d [ --decompress ] find '*.pjg' files and decompress them\n";
|
||
|
std::cout << " -k [ --keep-orig ] keep original files; don't delete them\n";
|
||
|
std::cout << " -f [ --filter ] regex with which to filter out input files\n";
|
||
|
std::cout << std::endl;
|
||
|
}
|
||
|
|
||
| ... | ... | |
|
("help,h", "display this help message")
|
||
|
("decompress,d", "find '*.pjg' files and decompress them")
|
||
|
("keep-orig,k", "keep orignal files")
|
||
|
("filter,f", bpo::value<std::string>(),
|
||
|
"regex with which to filter out input files")
|
||
|
("file_path", "path in which to recursively look for input files")
|
||
|
;
|
||
|
|
||
| ... | ... | |
|
|
||
|
// Parse general/positional options
|
||
|
bpo::store(bpo::command_line_parser(argc, argv).options(general_opts)
|
||
|
.positional(pos_opts).allow_unregistered().run(),
|
||
|
.positional(pos_opts).run(),
|
||
|
general_opts_vm);
|
||
|
|
||
|
|
||
|
// Display help if the option is listed or if no arguments are provided
|
||
|
if (general_opts_vm.count("help") || (argc == 1))
|
||
|
{
|
||
|
usage(argv);
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
|
bpo::notify(general_opts_vm);
|
||
|
}
|
||
|
catch (std::exception& e)
|
||
|
{
|
||
| ... | ... | |
|
return -1;
|
||
|
}
|
||
|
|
||
|
|
||
|
// Make a copy of the file search path for passing into the object below
|
||
|
std::string search_path(general_opts_vm["file_path"].as<std::string>());
|
||
|
|
||
| ... | ... | |
|
std::cout << " keep original files => ON\n";
|
||
|
}
|
||
|
|
||
|
// Check for, and if present validate the filter regex
|
||
|
boost::regex filter_regex("");
|
||
|
if (general_opts_vm.count("filter"))
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
filter_regex = general_opts_vm["filter"].as<std::string>().c_str();
|
||
|
}
|
||
|
catch (std::exception& e)
|
||
|
{
|
||
|
std::cerr << BOLD << RED << "ERROR: " << ENDC << "the filter \""
|
||
|
<< general_opts_vm["filter"].as<std::string>()
|
||
|
<< "\" is not a valid regular expression.\n";
|
||
|
std::cerr << " " << e.what() << std::endl;
|
||
|
return -1;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
std::cout << std::endl;
|
||
|
|
||
|
// Create the PCA object and let 'er rip!
|
||
|
auto pca = new PhotoCompressArchiver(search_path, num_cores, decompress,
|
||
|
keep_orig);
|
||
|
keep_orig, filter_regex);
|
||
|
pca->execute();
|
||
|
delete pca;
|
||
|
|
||
WIP commit. I started converting the argv list to a std::vector and adding logic to make sure it does not exceed the maximum argv size.