Elements 6.3.3
A C++ base framework for the Euclid Software.
Loading...
Searching...
No Matches
ProgramManager.tpp
Go to the documentation of this file.
1
20
21// IWYU pragma: private, include "ElementsKernel/ProgramManager.h"
22
23#ifndef ELEMENTSKERNEL_ELEMENTSKERNEL_PROGRAM_MANAGER_IMPL_
24#error "This file should not be included directly! Use ElementsKernel/ProgramManager.h instead"
25#else
26
27#include <iostream> // for operator<<, basic_ostream, char_traits, endl, cerr
28#include <stdlib.h> // for exit
29
30#include <boost/filesystem/operations.hpp> // for exists
31#include <boost/filesystem/path.hpp> // for operator<<
32
33#include "ElementsKernel/Exit.h" // for ExitCode
34#include "ElementsKernel/Path.h" // for Item
35
36namespace boost::program_options {
37template <class charT>
39}
40
41namespace Elements {
42
43template <class charT>
45 const boost::program_options::basic_parsed_options<charT>& cmd_parsed_options) {
46
47 for (const auto& o : cmd_parsed_options.options) {
48 if (o.string_key == "config-file") {
49 if (o.value.size() != 1) {
50 std::cerr << "Wrong usage of the --config-file option" << std::endl;
51 exit(static_cast<int>(ExitCode::USAGE));
52 } else {
53 auto conf_file = Path::Item{o.value[0]};
54 if (not boost::filesystem::exists(conf_file)) {
55 std::cerr << "The " << conf_file << " configuration file doesn't exist!" << std::endl;
56 exit(static_cast<int>(ExitCode::CONFIG));
57 }
58 }
59 }
60 }
61}
62
63} // namespace Elements
64
65#endif // ELEMENTSKERNEL_ELEMENTSKERNEL_PROGRAM_MANAGER_IMPL_
define a list of standard exit codes for executables
provide functions to retrieve resources pointed by environment variables
void checkCommandLineOptions(const boost::program_options::basic_parsed_options< charT > &cmd_line_options)
check the explicit command line arguments. For the moment, it only checks if the configuration file b...
T endl(T... args)
T exit(T... args)
@ CONFIG
configuration error
Definition Exit.h:117
@ USAGE
command line usage error
Definition Exit.h:103