fix(cli): check if successfully saved database after weeding

This commit is contained in:
Masahiko AMANO 2022-12-28 18:56:44 +03:00
parent 631716877b
commit 29df398a50

View File

@ -429,13 +429,13 @@ int main(int argc, char **argv) {
free(tanabata_path); free(tanabata_path);
fclose(config); fclose(config);
if (opt_w) { if (opt_w) {
if (tanabata_weed(&tanabata) != 0) { if (tanabata_weed(&tanabata) == 0 &&
fprintf(stderr, ERROR("Failed to weed database\n")); tanabata_save(&tanabata) == 0) {
return 1; printf(SUCCESS("Successfully weeded database\n"));
return 0;
} }
tanabata_save(&tanabata); fprintf(stderr, ERROR("Failed to weed database\n"));
printf(SUCCESS("Successfully weeded database\n")); return 1;
return 0;
} }
if (opt_a) { if (opt_a) {
if (opt_f) { if (opt_f) {