mirror of
https://github.com/KingDuckZ/dindexer.git
synced 2025-07-03 14:14:11 +00:00
Accept file or set ids on the command line
This commit is contained in:
parent
a508a22af8
commit
9ae2474f58
2 changed files with 21 additions and 9 deletions
|
@ -19,6 +19,7 @@
|
||||||
#include "dindexer-common/commandline.hpp"
|
#include "dindexer-common/commandline.hpp"
|
||||||
#include <boost/program_options.hpp>
|
#include <boost/program_options.hpp>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
namespace po = boost::program_options;
|
namespace po = boost::program_options;
|
||||||
|
|
||||||
|
@ -31,18 +32,18 @@ namespace din {
|
||||||
//("option2", po::value<int>(), "Help message")
|
//("option2", po::value<int>(), "Help message")
|
||||||
//;
|
//;
|
||||||
|
|
||||||
//po::options_description positional_options("Positional options");
|
po::options_description positional_options("Positional options");
|
||||||
//positional_options.add_options()
|
positional_options.add_options()
|
||||||
//("pos_option", po::value<std::string>(), "pos_option description")
|
("ids", po::value<std::vector<uint64_t>>(), "pos_option description")
|
||||||
//;
|
;
|
||||||
|
|
||||||
const auto desc = dinlib::get_default_commandline();
|
const auto desc = dinlib::get_default_commandline();
|
||||||
po::options_description all("Available options");
|
po::options_description all("Available options");
|
||||||
//po::positional_options_description pd;
|
po::positional_options_description pd;
|
||||||
all.add(desc)./*add(positional_options).*/add(set_options);
|
all.add(desc).add(positional_options).add(set_options);
|
||||||
//pd.add("pos_option", 1);//.add("pos_option2", 1);
|
pd.add("ids", -1);//.add("pos_option2", 1);
|
||||||
try {
|
try {
|
||||||
po::store(po::command_line_parser(parArgc, parArgv).options(all)/*.positional(pd)*/.run(), parVarMap);
|
po::store(po::command_line_parser(parArgc, parArgv).options(all).positional(pd).run(), parVarMap);
|
||||||
}
|
}
|
||||||
catch (const po::validation_error& err) {
|
catch (const po::validation_error& err) {
|
||||||
throw dinlib::ValidationError(err);
|
throw dinlib::ValidationError(err);
|
||||||
|
@ -50,7 +51,7 @@ namespace din {
|
||||||
|
|
||||||
po::notify(parVarMap);
|
po::notify(parVarMap);
|
||||||
|
|
||||||
if (dinlib::manage_common_commandline(std::cout, ACTION_NAME, "[options...] <search-path>", parVarMap, {std::cref(desc), std::cref(set_options)})) {
|
if (dinlib::manage_common_commandline(std::cout, ACTION_NAME, "[options...] ids...", parVarMap, {std::cref(desc), std::cref(set_options)})) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "commandline.hpp"
|
#include "commandline.hpp"
|
||||||
|
#include "tag_postgres.hpp"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <ciso646>
|
#include <ciso646>
|
||||||
|
|
||||||
|
@ -32,5 +33,15 @@ int main (int parArgc, char* parArgv[]) {
|
||||||
std::cerr << err.what() << "\nUse --help for help" << std::endl;
|
std::cerr << err.what() << "\nUse --help for help" << std::endl;
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (not vm.count("ids")) {
|
||||||
|
std::cerr << "No IDs specified\n";
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto ids = vm["ids"].as<std::vector<uint64_t>>();
|
||||||
|
for (auto id : ids) {
|
||||||
|
std::cout << id << '\n';
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue