flexiblesusy is hosted by Hepforge, IPPP Durham
FlexibleSUSY
command_line_options.cpp
Go to the documentation of this file.
1// ====================================================================
2// This file is part of FlexibleSUSY.
3//
4// FlexibleSUSY is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published
6// by the Free Software Foundation, either version 3 of the License,
7// or (at your option) any later version.
8//
9// FlexibleSUSY is distributed in the hope that it will be useful, but
10// WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12// General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with FlexibleSUSY. If not, see
16// <http://www.gnu.org/licenses/>.
17// ====================================================================
18
20#include "array_view.hpp"
21#include "build_info.hpp"
22#include "logger.hpp"
23
24#include <cstdio>
25
26namespace flexiblesusy {
27
30{
31}
32
34{
35 parse(args);
36}
37
45{
46 reset();
47
48 if (args.empty())
49 return;
50
51 program = args[0];
52
53 for (int i = 1; i < args.size(); ++i) {
54 const std::string option(args[i]);
55 if (starts_with(option,"--slha-input-file=")) {
56 slha_input_file = option.substr(18);
57 } else if (starts_with(option,"--slha-output-file=")) {
58 slha_output_file = option.substr(19);
59 } else if (starts_with(option,"--spectrum-output-file=")) {
60 spectrum_file = option.substr(23);
61 } else if (starts_with(option,"--database-output-file=")) {
62 database_output_file = option.substr(23);
63 } else if (starts_with(option,"--rgflow-output-file=")) {
64 rgflow_file = option.substr(21);
65 } else if (option == "--help" || option == "-h") {
66 print_usage(std::cout);
67 do_exit = true;
68 } else if (option == "--build-info") {
69 print_build_info(std::cout);
70 do_exit = true;
71 } else if (option == "--model-info") {
73 do_exit = true;
74 } else if (starts_with(option, "--higgssignals-dataset=")) {
75 higgssignals_dataset = option.substr(23);
76 } else if (starts_with(option, "--higgsbounds-dataset=")) {
77 higgsbounds_dataset = option.substr(22);
78 } else if (option == "--version" || option == "-v") {
79 print_version(std::cout);
80 do_exit = true;
81 } else {
82 ERROR("Unrecognized command line option: " << option);
83 do_exit = true;
84 exit_status = EXIT_FAILURE;
85 }
86 }
87}
88
89void Command_line_options::print_build_info(std::ostream& ostr) const
90{
92}
93
94void Command_line_options::print_version(std::ostream& ostr) const
95{
96 ostr << "FlexibleSUSY ";
98 ostr << std::endl;
99}
100
101void Command_line_options::print_usage(std::ostream& ostr) const
102{
103 ostr << "Usage: " << program << " [options]\n"
104 "Options:\n"
105 " --slha-input-file=<filename> SLHA input file (default: )\n"
106 " If <filename> is - then the"
107 " SLHA input\n"
108 " is read from stdin.\n"
109 " --slha-output-file=<filename> SLHA output file (default: -)\n"
110 " If <filename> is the empty string, then\n"
111 " no SLHA output is written.\n"
112 " If <filename> is - then the output is\n"
113 " printed to stdout.\n"
114 " --spectrum-output-file=<filename> File to write spectrum to\n"
115 " --database-output-file=<filename> SQLite database file to write\n"
116 " parameter point to\n"
117 " --higgsbounds-dataset=<directory> Location of HiggsBounds dataset\n"
118 " --higgssignals-dataset=<directory> Location of HiggsSignals dataset\n"
119 " --rgflow-output-file=<filename> File to write rgflow to\n"
120 " --build-info Print build information\n"
121 " --model-info Print model information\n"
122 " --help,-h Print this help message\n"
123 " --version,-v Print program version"
124 << std::endl;
125}
126
131{
132 *this = Command_line_options();
133}
134
143bool Command_line_options::starts_with(const std::string& str,
144 const std::string& prefix)
145{
146 return !str.compare(0, prefix.size(), prefix);
147}
148
160 const std::string& prefix,
161 double& parameter)
162{
163 if (starts_with(str, prefix)) {
164 parameter = std::stod(str.substr(prefix.length()));
165 return true;
166 }
167 return false;
168}
169
181 const std::string& prefix,
182 int& parameter)
183{
184 if (starts_with(str, prefix)) {
185 parameter = std::stoi(str.substr(prefix.length()));
186 return true;
187 }
188 return false;
189}
190
191} // namespace flexiblesusy
parses the command line options
static bool get_parameter_value(const std::string &, const std::string &, double &)
void print_version(std::ostream &) const
void parse(const Dynamic_array_view< char * > &)
static bool starts_with(const std::string &, const std::string &)
void print_usage(std::ostream &) const
void print_build_info(std::ostream &) const
constexpr Index_t size() const noexcept
Definition: array_view.hpp:93
constexpr bool empty() const noexcept
Definition: array_view.hpp:92
#define ERROR(msg)
Definition: logger.hpp:65
void print_flexiblesusy_version(std::ostream &ostr)
Definition: build_info.cpp:50
constexpr Dynamic_array_view< ElementType > make_dynamic_array_view(ElementType *ptr, std::ptrdiff_t len)
Definition: array_view.hpp:125
void print_all_info(std::ostream &ostr)
Definition: build_info.cpp:30