168{
169 const char *usage = "Usage: profile_include_dump -p <profiles dir> -o <dump file> [-v <vendor>] [-l <log level>] [-c]\n"
170 " -v vendor to dump, BBL if omitted\n"
171 " -l log level, 0 (fatal) to 5 (trace); 1 if omitted\n"
172 " -c load the presets from the vendor's preset cache, generated first, not the JSON\n";
173 std::string dir, output, vendor = "BBL";
174 unsigned log_level = 1;
175 bool from_cache = false;
176 for (int i = 1; i < argc; ++i) {
177 const std::string arg = argv[i];
178 if (arg == "-c") {
179 from_cache = true;
180 continue;
181 }
182 if (i + 1 == argc) {
183 std::cerr << usage;
184 return 1;
185 }
186 const std::string value = argv[++i];
187 if (arg == "-p")
188 dir = value;
189 else if (arg == "-o")
190 output = value;
191 else if (arg == "-v")
192 vendor = value;
193 else if (arg == "-l" && value.size() == 1 && value[0] >= '0' && value[0] <= '5')
194 log_level = unsigned(value[0] - '0');
195 else {
196 std::cerr << usage;
197 return 1;
198 }
199 }
200 if (dir.empty() || output.empty() || !fs::is_directory(dir)) {
201 std::cerr << usage;
202 return 1;
203 }
205
206 try {
209 boost::nowide::ofstream out(output);
210 if (!out)
211 throw std::runtime_error("Cannot write " + output);
213 out.close();
214 if (!out)
215 throw std::runtime_error("Failed writing " + output);
216 std::cerr << "Dumped " << dumped << " " << vendor << " presets that include a template\n";
217 } catch (const std::exception &ex) {
218 std::cerr << ex.what() << "\n";
219 return 1;
220 }
221 return 0;
222}
Definition PresetBundle.hpp:210
void set_logging_level(unsigned int level)
Definition utils.cpp:171
void load_vendor(PresetBundle &bundle, const std::string &dir, const std::string &vendor, bool from_cache)
Definition profile_include_dump.cpp:134
Sections read_vendor(const fs::path &dir, const std::string &vendor)
Definition profile_include_dump.cpp:57
size_t dump(const PresetBundle &bundle, const Sections §ions, std::ostream &out)
Definition profile_include_dump.cpp:96