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
32
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 (starts_with(option, "--lilith-db=")) {
79 lilith_db = option.substr(12);
80 } else if (option == "--version" || option == "-v") {
81 print_version(std::cout);
82 do_exit = true;
83 } else {
84 ERROR("Unrecognized command line option: " << option);
85 do_exit = true;
86 exit_status = EXIT_FAILURE;
87 }
88 }
89}
90
91void Command_line_options::print_build_info(std::ostream& ostr) const
92{
94}
95
96void Command_line_options::print_version(std::ostream& ostr) const
97{
98 ostr << "FlexibleSUSY ";
100 ostr << std::endl;
101}
102
103void Command_line_options::print_usage(std::ostream& ostr) const
104{
105 ostr << "Usage: " << program << " [options]\n"
106 "Options:\n"
107 " --slha-input-file=<filename> SLHA input file (default: )\n"
108 " If <filename> is - then the"
109 " SLHA input\n"
110 " is read from stdin.\n"
111 " --slha-output-file=<filename> SLHA output file (default: -)\n"
112 " If <filename> is the empty string, then\n"
113 " no SLHA output is written.\n"
114 " If <filename> is - then the output is\n"
115 " printed to stdout.\n"
116 " --spectrum-output-file=<filename> File to write spectrum to\n"
117 " --database-output-file=<filename> SQLite database file to write\n"
118 " parameter point to\n"
119 " --higgsbounds-dataset=<directory> Location of HiggsBounds dataset\n"
120 " --higgssignals-dataset=<directory> Location of HiggsSignals dataset\n"
121 " --lilith-db=<filename> Lilith database\n"
122 " --rgflow-output-file=<filename> File to write rgflow to\n"
123 " --build-info Print build information\n"
124 " --model-info Print model information\n"
125 " --help,-h Print this help message\n"
126 " --version,-v Print program version"
127 << std::endl;
128}
129
134{
135 *this = Command_line_options();
136}
137
146bool Command_line_options::starts_with(const std::string& str,
147 const std::string& prefix)
148{
149 return !str.compare(0, prefix.size(), prefix);
150}
151
163 const std::string& prefix,
164 double& parameter)
165{
166 if (starts_with(str, prefix)) {
167 parameter = std::stod(str.substr(prefix.length()));
168 return true;
169 }
170 return false;
171}
172
184 const std::string& prefix,
185 int& parameter)
186{
187 if (starts_with(str, prefix)) {
188 parameter = std::stoi(str.substr(prefix.length()));
189 return true;
190 }
191 return false;
192}
193
194} // 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_build_info(std::ostream &) const
constexpr Index_t size() const noexcept
constexpr bool empty() const noexcept
#define ERROR(msg)
Definition logger.hpp:65
void print_flexiblesusy_version(std::ostream &ostr)
constexpr Dynamic_array_view< ElementType > make_dynamic_array_view(ElementType *ptr, std::ptrdiff_t len)
void print_all_info(std::ostream &ostr)