Compare commits

..

3 Commits

2 changed files with 5 additions and 4 deletions

View File

@ -118,6 +118,7 @@ int cmd_delete(int argc, char *argv[]) {
if(not db.recipe_exists(id)) {
std::cerr << "No recipe exists with ID " << id << "." << std::endl;
db.close();
return EXIT_FAILURE;
} else {
recipe_ids.push_back(id);
@ -134,12 +135,12 @@ int cmd_info(const int id) {
db db;
struct recipe recipe;
std::vector<std::string> ingredients, tags;
int ret = EXIT_SUCCESS;
db.open();
if(not db.recipe_exists(id)) {
std::cerr << "No recipe with ID '" << id << "'";
db.close();
return EXIT_FAILURE;
}
@ -164,5 +165,5 @@ int cmd_info(const int id) {
std::cout << "\t- " << tag << std::endl;
std::cout << std::endl;
return ret;
return EXIT_SUCCESS;
}

View File

@ -54,7 +54,7 @@ public:
inline int get_recipe_id(const std::string &name) {
return table_get_id_by_name("recipes", name);
}
inline bool db_recipe_exists(const std::string &name) {
inline bool recipe_exists(const std::string &name) {
return (get_recipe_id(name) > 0);
}
bool recipe_exists(const int id);
@ -74,7 +74,7 @@ public:
inline int get_ingredient_id(const std::string &name) {
return table_get_id_by_name("ingredients", name);
}
inline bool db_ingredient_exists(const std::string &name) {
inline bool ingredient_exists(const std::string &name) {
return (get_ingredient_id(name) > 0);
}