Add feature to edit name.

And documentation for editing the description.
This commit is contained in:
2024-10-21 18:37:53 +02:00
parent 0b348e8c10
commit 320346911c
8 changed files with 61 additions and 4 deletions

View File

@@ -168,6 +168,27 @@ int cmd_info(const int id) {
return EXIT_SUCCESS;
}
int cmd_edit_name(const int id) {
db db;
std::string new_name;
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_name);
db.update_recipe_name(id, new_name);
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, ",");