Skip to content

Commit 9d2ab60

Browse files
committed
feat: Handle validate as errors
1 parent c27ed80 commit 9d2ab60

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

ecsact/cli/commands/build.cc

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
namespace fs = std::filesystem;
2727

2828
using namespace std::string_view_literals;
29+
using namespace std::string_literals;
2930

3031
constexpr auto USAGE = R"docopt(Ecsact Build Command
3132
@@ -187,7 +188,15 @@ auto ecsact::cli::detail::build_command( //
187188
}
188189

189190
for(auto plugin : result->plugins) {
190-
ecsact::codegen::plugin_validate(plugin);
191+
auto validate_result = ecsact::codegen::plugin_validate(plugin);
192+
if(!validate_result.ok()) {
193+
auto err_msg = "Plugin validation failed for '" + plugin + "'\n";
194+
for(auto err : validate_result.errors) {
195+
err_msg += " - "s + to_string(err) + "\n";
196+
}
197+
ecsact::cli::report_error("{}", err_msg);
198+
return 1;
199+
}
191200
}
192201
}
193202
}

ecsact/cli/commands/recipe-bundle.cc

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
namespace fs = std::filesystem;
2323

2424
using namespace std::string_view_literals;
25+
using namespace std::string_literals;
2526

2627
constexpr auto USAGE = R"docopt(Ecsact Recipe Bundle Command
2728
@@ -109,7 +110,15 @@ auto ecsact::cli::detail::recipe_bundle_command( //
109110
}
110111

111112
for(auto plugin : result->plugins) {
112-
ecsact::codegen::plugin_validate(plugin);
113+
auto validate_result = ecsact::codegen::plugin_validate(plugin);
114+
if(!validate_result.ok()) {
115+
auto err_msg = "Plugin validation failed for '" + plugin + "'\n";
116+
for(auto err : validate_result.errors) {
117+
err_msg += " - "s + to_string(err) + "\n";
118+
}
119+
ecsact::cli::report_error("{}", err_msg);
120+
return 1;
121+
}
113122
}
114123
}
115124
}

0 commit comments

Comments
 (0)