Commit aaa34a54 authored by Simon Spannagel's avatar Simon Spannagel
Browse files

Corry: allow CLI options with "-o" just as Allpix Squared

parent a7e16a3c
......@@ -20,7 +20,7 @@
using namespace corryvreckan;
// Default constructor
Analysis::Analysis(std::string config_file_name) : m_terminate(false) {
Analysis::Analysis(std::string config_file_name, std::vector<std::string> options) : m_terminate(false) {
// Load the global configuration
conf_mgr_ = std::make_unique<corryvreckan::ConfigManager>(std::move(config_file_name));
......@@ -30,6 +30,11 @@ Analysis::Analysis(std::string config_file_name) : m_terminate(false) {
conf_mgr_->addGlobalHeaderName("");
conf_mgr_->addIgnoreHeaderName("Ignore");
// Parse all command line options
for(auto& option : options) {
conf_mgr_->parseOption(option);
}
// Fetch the global configuration
global_config = conf_mgr_->getGlobalConfiguration();
......
......@@ -31,7 +31,7 @@ namespace corryvreckan {
public:
// Constructors and destructors
Analysis(std::string config_file_name);
explicit Analysis(std::string config_file_name, std::vector<std::string> options = std::vector<std::string>());
virtual ~Analysis(){};
// Member functions
......
......@@ -86,6 +86,7 @@ int main(int argc, const char* argv[]) {
// Parse arguments
std::string config_file_name;
std::string log_file_name;
std::vector<std::string> options;
for(int i = 1; i < argc; i++) {
if(strcmp(argv[i], "-h") == 0) {
print_help = true;
......@@ -100,6 +101,8 @@ int main(int argc, const char* argv[]) {
config_file_name = std::string(argv[++i]);
} else if(strcmp(argv[i], "-l") == 0 && (i + 1 < argc)) {
log_file_name = std::string(argv[++i]);
} else if(strcmp(argv[i], "-o") == 0 && (i + 1 < argc)) {
options.emplace_back(std::string(argv[++i]));
} else {
LOG(ERROR) << "Unrecognized command line argument \"" << argv[i] << "\"";
print_help = true;
......@@ -110,10 +113,10 @@ int main(int argc, const char* argv[]) {
// Print help if requested or no arguments given
if(print_help) {
std::cout << "Usage: corry -c <config> [-v <level>]" << std::endl;
std::cout << "\t -c <file> configuration file to be used" << std::endl;
std::cout << "\t -l <file> file to log to besides standard output" << std::endl;
std::cout << "\t -v <level> verbosity level overwrites global level,\n"
<< "\t but not the per-module configuration." << std::endl;
std::cout << " -c <file> configuration file to be used" << std::endl;
std::cout << " -l <file> file to log to besides standard output" << std::endl;
std::cout << " -o <option> extra configuration option(s) to pass" << std::endl;
std::cout << " -v <level> verbosity level, overwriting the global level" << std::endl;
clean();
return return_code;
}
......@@ -142,7 +145,7 @@ int main(int argc, const char* argv[]) {
try {
// Construct main Allpix object
corry = std::make_unique<Analysis>(config_file_name);
corry = std::make_unique<Analysis>(config_file_name, options);
cv_ready = true;
// Load modules
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment