| 151 | } |
| 152 | |
| 153 | void ClientApplicationBase::init(int argc, char ** argv) |
| 154 | { |
| 155 | namespace po = boost::program_options; |
| 156 | |
| 157 | /// Don't parse options with Poco library, we prefer neat boost::program_options. |
| 158 | stopOptionsProcessing(); |
| 159 | |
| 160 | std::vector<Arguments> external_tables_arguments; |
| 161 | Arguments common_arguments = {""}; /// 0th argument is ignored. |
| 162 | std::vector<Arguments> hosts_and_ports_arguments; |
| 163 | |
| 164 | if (argc) |
| 165 | argv0 = argv[0]; |
| 166 | |
| 167 | /// Set application name for help messages based on how the binary was invoked |
| 168 | std::string_view argv0_view(argv0 ? argv0 : ""); |
| 169 | std::string name_with_dash = "clickhouse-" + getName(); |
| 170 | if (argv0_view.find(name_with_dash) != std::string_view::npos) |
| 171 | app_name = name_with_dash; |
| 172 | else |
| 173 | app_name = "clickhouse " + getName(); |
| 174 | |
| 175 | readArguments(argc, argv, common_arguments, external_tables_arguments, hosts_and_ports_arguments); |
| 176 | |
| 177 | /// Support for Unicode dashes |
| 178 | /// Interpret Unicode dashes as default double-hyphen |
| 179 | for (auto & arg : common_arguments) |
| 180 | { |
| 181 | // replace em-dash(U+2014) |
| 182 | boost::replace_all(arg, "—", "--"); |
| 183 | // replace en-dash(U+2013) |
| 184 | boost::replace_all(arg, "–", "--"); |
| 185 | // replace mathematical minus(U+2212) |
| 186 | boost::replace_all(arg, "−", "--"); |
| 187 | } |
| 188 | |
| 189 | OptionsDescription options_description; |
| 190 | addCommonOptions(options_description); |
| 191 | addExtraOptions(options_description); |
| 192 | /// Copy them to be able to print a simplified version of the help message. |
| 193 | OptionsDescription options_description_non_verbose = options_description; |
| 194 | addSettingsToProgramOptionsAndSubscribeToChanges(options_description); |
| 195 | addOptionsToHints(options_description); |
| 196 | |
| 197 | po::variables_map options; |
| 198 | parseAndCheckOptions(options_description, options, common_arguments); |
| 199 | po::notify(options); |
| 200 | |
| 201 | if (options.contains("version") || options.contains("V")) |
| 202 | { |
| 203 | showClientVersion(); |
| 204 | exit(0); // NOLINT(concurrency-mt-unsafe) |
| 205 | } |
| 206 | |
| 207 | if (options.contains("version-clean")) |
| 208 | { |
| 209 | output_stream << VERSION_STRING; |
| 210 | exit(0); // NOLINT(concurrency-mt-unsafe) |
nothing calls this directly
no test coverage detected