Skip to content

Commit e214b90

Browse files
committed
Exit properly on CLI error.
1 parent a090ae5 commit e214b90

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

source/cli/metacallcli/source/application.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ void application::repl()
4949
}
5050

5151
/* Register exit function */
52-
auto exit = [](size_t argc, void *args[], void *data) -> void * {
52+
auto exit_command = [](size_t argc, void *args[], void *data) -> void * {
5353
(void)args;
5454
(void)data;
5555

@@ -67,11 +67,12 @@ void application::repl()
6767
return NULL;
6868
};
6969

70-
int result = metacall_register_loaderv(metacall_loader("ext"), plugin_repl_handle, "exit", exit, METACALL_INVALID, 0, NULL);
70+
int result = metacall_register_loaderv(metacall_loader("ext"), plugin_repl_handle, "exit", exit_command, METACALL_INVALID, 0, NULL);
7171

7272
if (result != 0)
7373
{
7474
std::cout << "Exit function was not registered properly, return code: " << result << std::endl;
75+
exit(1);
7576
}
7677
else
7778
{
@@ -268,7 +269,7 @@ application::application(int argc, char *argv[]) :
268269
if (metacall_initialize() != 0)
269270
{
270271
/* Exit from application */
271-
return;
272+
exit(1);
272273
}
273274

274275
/* Initialize MetaCall arguments */
@@ -372,7 +373,7 @@ void application::arguments_parse(std::vector<std::string> &arguments)
372373
{
373374
/* Stop loading more scripts */
374375
std::cout << "Error: Failed to load script '" << script << "' with loader '" << safe_tag << "'" << std::endl;
375-
return;
376+
exit(1);
376377
}
377378
}
378379
}

0 commit comments

Comments
 (0)