Add feature to edit recipe description.

This commit is contained in:
2024-10-21 18:44:38 +02:00
parent 320346911c
commit 009e3f09bf
7 changed files with 52 additions and 13 deletions

View File

@@ -189,6 +189,27 @@ int cmd_edit_name(const int id) {
return EXIT_SUCCESS;
}
int cmd_edit_desc(const int id) {
db db;
std::string new_desc;
db.open();
if(not db.recipe_exists(id)) {
std::cerr << "Recipe with ID " << id << " does not exist." << std::endl;
db.close();
return EXIT_FAILURE;
}
std::cout << "New name: ";
std::getline(std::cin, new_desc);
db.update_recipe_desc(id, new_desc);
db.close();
return EXIT_SUCCESS;
}
int cmd_add_ingr(const int recipe_id, const char *ingredients) {
db db;
std::vector<std::string> ingr_list = split(ingredients, ",");