Skip to content

Commit

Permalink
feat: Added exit code support for handling from CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
mallo-m committed Jan 10, 2025
1 parent 46999b6 commit 5178b5a
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions include/swappy.h
Original file line number Diff line number Diff line change
Expand Up @@ -189,4 +189,5 @@ struct swappy_state {

int argc;
char **argv;
int exit_code;
};
1 change: 1 addition & 0 deletions src/application.c
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,7 @@ void window_keypress_handler(GtkWidget *widget, GdkEventKey *event,
case GDK_KEY_Escape:
case GDK_KEY_q:
maybe_save_output_file(state);
state->exit_code = 1;
gtk_main_quit();
break;
case GDK_KEY_b:
Expand Down
3 changes: 2 additions & 1 deletion src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ int main(int argc, char *argv[]) {
state.argc = argc;
state.argv = argv;
state.mode = SWAPPY_PAINT_MODE_BRUSH;
state.exit_code = 0;

if (!application_init(&state)) {
g_critical("failed to initialize gtk application");
Expand All @@ -24,5 +25,5 @@ int main(int argc, char *argv[]) {

application_finish(&state);

return status;
return state.exit_code;
}

0 comments on commit 5178b5a

Please sign in to comment.