MCPcopy Create free account
hub / github.com/GaijinEntertainment/daScript / run

Function run

utils/dasFormatter/fmt.cpp:263–295  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

261}
262
263int run(FormatOptions opts, const vector<string> &files) {
264 int ret_code = 0;
265 TextPrinter tp;
266 if (files.size() > 1 && !opts.contains(FormatOpt::Inplace)) {
267 tp << "Expected inplace mode in case of more than 1 file\n";
268 }
269 for (const auto &file: files) {
270 tp << "input file=" << file << '\n';
271 std::ifstream t(file.c_str());
272
273 string str(std::string((std::istreambuf_iterator<char>(t)),
274 std::istreambuf_iterator<char>()).c_str());
275
276 auto res = transform_syntax(file, str, opts);
277 if (res.ok) {
278 if (opts.contains(FormatOpt::Inplace)) {
279 std::ofstream out(file.c_str());
280 out << res.ok.value().c_str();
281 } else {
282 tp << res.ok.value().c_str();
283 }
284 } else if (res.error) {
285 if (!opts.contains(FormatOpt::Inplace)) {
286 tp << res.error->content << '\n';
287 }
288 tp << file << '\n' << res.error->what << '\n';
289 ret_code = -1;
290 } else {
291 tp << "cant_compile=" << file << '\n';
292 }
293 }
294 return ret_code;
295}
296}

Callers 6

releaseFunction · 0.85
MAIN_FUNC_NAMEFunction · 0.85
mainFunction · 0.85
normalizeOptionTypesMethod · 0.85
correctness_sweepFunction · 0.85
DOCTEST_DEFINE_DECORATORFunction · 0.85

Calls 6

stringClass · 0.85
transform_syntaxFunction · 0.85
sizeMethod · 0.45
containsMethod · 0.45
c_strMethod · 0.45
valueMethod · 0.45

Tested by 1

DOCTEST_DEFINE_DECORATORFunction · 0.68