LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
artapp.cc
Go to the documentation of this file.
2 // vim: set sw=2 expandtab :
3 
13 #include "cetlib/filepath_maker.h"
14 
15 #include "boost/filesystem.hpp"
16 #include "boost/program_options.hpp"
17 
18 #include <iostream>
19 #include <string>
20 
21 namespace bpo = boost::program_options;
22 
23 using namespace std;
24 
25 int
26 artapp(int argc, char* argv[], bool report_unused)
27 {
28  // Configuration file lookup policy.
29  string search_path;
30  if (char const* fhicl_env = std::getenv("FHICL_FILE_PATH")) {
31  search_path = string{fhicl_env};
32  } else {
33  cerr << "Expected environment variable FHICL_FILE_PATH is missing or "
34  "empty: using \".\"\n";
35  search_path = ".";
36  }
37  cet::filepath_first_absolute_or_lookup_with_dot lookupPolicy{search_path};
38 
39  // Create and store options handlers.
40  ostringstream descstr;
41  descstr << "\nUsage: " << boost::filesystem::path(argv[0]).filename().native()
42  << " <-c <config-file>> <other-options> [<source-file>]+\n\n"
43  << "Basic options";
44  bpo::options_description all_desc{descstr.str()};
45  art::OptionsHandlers handlers;
46  handlers.reserve(7);
47  // BasicOptionsHandler should always be first in the list!
48  handlers.emplace_back(
49  new art::BasicOptionsHandler{all_desc, lookupPolicy, report_unused});
50  // Additional options
51  handlers.emplace_back(new art::BasicSourceOptionsHandler{all_desc});
52  handlers.emplace_back(new art::BasicOutputOptionsHandler{all_desc});
53  handlers.emplace_back(new art::ProcessingOptionsHandler{all_desc});
54  handlers.emplace_back(new art::DebugOptionsHandler{all_desc});
55  handlers.emplace_back(new art::FileCatalogOptionsHandler{all_desc});
56  // BasicPostProcessor should be last.
57  handlers.emplace_back(new art::BasicPostProcessor);
58  return art::run_art(argc, argv, all_desc, std::move(handlers));
59 }
60 
61 // Local Variables:
62 // mode: c++
63 // End:
STL namespace.
std::vector< std::unique_ptr< art::OptionsHandler >> OptionsHandlers
int artapp(int argc, char *argv[], bool report_unused)
Definition: artapp.cc:26
int run_art(int argc, char **argv, bpo::options_description &all_desc, OptionsHandlers &&handlers)
Definition: run_art.cc:142