@@ -82,7 +82,7 @@ ignore_setting(const Tp& _v)
82
82
category_view.count (" settings::deprecated" ) == 0 &&
83
83
_v->get_categories ().count (" deprecated" ) > 0 )
84
84
return true ;
85
- if (category_view.count (" advanced" ) == 0 &&
85
+ if (!print_advanced && category_view.count (" advanced" ) == 0 &&
86
86
category_view.count (" settings::advanced" ) == 0 &&
87
87
_v->get_categories ().count (" advanced" ) > 0 )
88
88
return true ;
@@ -209,17 +209,28 @@ generate_config(std::string _config_file, const std::set<std::string>& _config_f
209
209
}
210
210
_output_dir += " /" ;
211
211
212
+ auto _fmts = std::set<std::string>{};
212
213
std::string _txt_ext = " .cfg" ;
213
214
for (std::string itr : { " .cfg" , " .txt" , " .json" , " .xml" })
214
215
{
216
+ if (_config_file.length () <= itr.length ()) continue ;
215
217
auto _pos = _config_file.rfind (itr);
216
218
if (_pos == _config_file.length () - itr.length ())
217
219
{
218
220
if (itr == " .cfg" || itr == " .txt" ) _txt_ext = itr;
221
+ _fmts.emplace (itr.substr (1 ));
219
222
_config_file = _config_file.substr (0 , _pos);
220
223
}
221
224
}
222
225
226
+ if (_fmts.empty () && _config_fmts.size () == 1 )
227
+ _fmts = _config_fmts;
228
+ else if (!_fmts.empty ())
229
+ {
230
+ for (auto & itr : _config_fmts)
231
+ _fmts.emplace (itr);
232
+ }
233
+
223
234
update_choices (_settings);
224
235
225
236
using json_t = cereal::PrettyJSONOutputArchive;
@@ -239,8 +250,10 @@ generate_config(std::string _config_file, const std::set<std::string>& _config_f
239
250
_ar->finishNode ();
240
251
};
241
252
242
- auto _open = [](std::ofstream& _ofs, const std::string& _fname,
243
- const std::string& _type) -> std::ofstream& {
253
+ auto _nout = 0 ;
254
+ auto _open = [&_nout](std::ofstream& _ofs, const std::string& _fname,
255
+ const std::string& _type) -> std::ofstream& {
256
+ ++_nout;
244
257
if (file_exists (_fname))
245
258
{
246
259
if (force_config)
@@ -273,7 +286,7 @@ generate_config(std::string _config_file, const std::set<std::string>& _config_f
273
286
return _ofs;
274
287
};
275
288
276
- if (_config_fmts .count (" json" ) > 0 )
289
+ if (_fmts .count (" json" ) > 0 )
277
290
{
278
291
std::stringstream _ss{};
279
292
output_archive<cereal::PrettyJSONOutputArchive>::indent_length () = 4 ;
@@ -284,7 +297,7 @@ generate_config(std::string _config_file, const std::set<std::string>& _config_f
284
297
_open (ofs, _fname, " JSON" ) << _ss.str () << " \n " ;
285
298
}
286
299
287
- if (_config_fmts .count (" xml" ) > 0 )
300
+ if (_fmts .count (" xml" ) > 0 )
288
301
{
289
302
std::stringstream _ss{};
290
303
output_archive<cereal::XMLOutputArchive>::indent () = true ;
@@ -295,7 +308,7 @@ generate_config(std::string _config_file, const std::set<std::string>& _config_f
295
308
_open (ofs, _fname, " XML" ) << _ss.str () << " \n " ;
296
309
}
297
310
298
- if (_config_fmts .count (" txt" ) > 0 )
311
+ if (_fmts .count (" txt" ) > 0 || _fmts. count ( " cfg " ) > 0 || _nout == 0 )
299
312
{
300
313
std::stringstream _ss{};
301
314
size_t _w = min_width;
0 commit comments