@@ -26,7 +26,7 @@ constexpr auto file_readonly_perms =
26
26
constexpr auto USAGE = R"( Ecsact Codegen Command
27
27
28
28
Usage:
29
- ecsact codegen <files> --plugin=<plugin> [--stdout]
29
+ ecsact codegen <files>... --plugin=<plugin> [--stdout]
30
30
ecsact codegen <files>... --plugin=<plugin>... [--outdir=<directory>]
31
31
32
32
Options:
@@ -238,42 +238,47 @@ int ecsact::cli::detail::codegen_command(int argc, char* argv[]) {
238
238
}
239
239
}
240
240
241
- for (auto package_id : package_ids) {
242
- fs::path output_file_path = ecsact_meta_package_file_path (package_id);
243
- if (output_file_path.empty ()) {
244
- std::cerr
245
- << " [ERROR] Could not find package source file path from "
246
- << " 'ecsact_meta_package_file_path'\n " ;
247
- continue ;
248
- }
241
+ if (args.at (" --stdout" ).asBool ()) {
242
+ plugin_fn (*package_ids.begin (), &stdout_write_fn);
243
+ std::cout.flush ();
244
+ } else {
245
+ for (auto package_id : package_ids) {
246
+ fs::path output_file_path = ecsact_meta_package_file_path (package_id);
247
+ if (output_file_path.empty ()) {
248
+ std::cerr
249
+ << " [ERROR] Could not find package source file path from "
250
+ << " 'ecsact_meta_package_file_path'\n " ;
251
+ continue ;
252
+ }
249
253
250
- output_file_path.replace_extension (
251
- output_file_path.extension ().string () + " ." + plugin_name
252
- );
254
+ output_file_path.replace_extension (
255
+ output_file_path.extension ().string () + " ." + plugin_name
256
+ );
253
257
254
- if (outdir) {
255
- output_file_path = *outdir / output_file_path.filename ();
256
- }
258
+ if (outdir) {
259
+ output_file_path = *outdir / output_file_path.filename ();
260
+ }
257
261
258
- if (output_paths.contains (output_file_path.string ())) {
259
- has_plugin_error = true ;
260
- std::cerr
261
- << " [ERROR] Plugin '"
262
- << plugin.location ().filename ().string ()
263
- << " ' has conflicts with another plugin output file '"
264
- << output_file_path.string () << " '\n " ;
265
- continue ;
266
- }
262
+ if (output_paths.contains (output_file_path.string ())) {
263
+ has_plugin_error = true ;
264
+ std::cerr
265
+ << " [ERROR] Plugin '"
266
+ << plugin.location ().filename ().string ()
267
+ << " ' has conflicts with another plugin output file '"
268
+ << output_file_path.string () << " '\n " ;
269
+ continue ;
270
+ }
267
271
268
- output_paths.emplace (output_file_path.string ());
269
- if (fs::exists (output_file_path)) {
270
- fs::permissions (output_file_path, fs::perms::all);
272
+ output_paths.emplace (output_file_path.string ());
273
+ if (fs::exists (output_file_path)) {
274
+ fs::permissions (output_file_path, fs::perms::all);
275
+ }
276
+ file_write_stream.open (output_file_path);
277
+ plugin_fn (package_id, &file_write_fn);
278
+ file_write_stream.flush ();
279
+ file_write_stream.close ();
280
+ fs::permissions (output_file_path, file_readonly_perms);
271
281
}
272
- file_write_stream.open (output_file_path);
273
- plugin_fn (package_id, &file_write_fn);
274
- file_write_stream.flush ();
275
- file_write_stream.close ();
276
- fs::permissions (output_file_path, file_readonly_perms);
277
282
}
278
283
279
284
plugin.unload ();
0 commit comments