From a0bdc982adfea822a70849e779b2bb91285817ab Mon Sep 17 00:00:00 2001 From: Anastasios Grammenos Date: Wed, 9 Nov 2022 16:32:08 +0200 Subject: testing new feature --- src/cook.c | 41 ++++++++++++++++++++++++++++++++++------- 1 file changed, 34 insertions(+), 7 deletions(-) diff --git a/src/cook.c b/src/cook.c index 74374f0..19eaa14 100644 --- a/src/cook.c +++ b/src/cook.c @@ -106,16 +106,43 @@ main(int argc, char * argv[]) return 0; } + /* if (opt.new) { */ + /* if (strcmp(opt.title, "")) */ + /* printf("@%s\n\n", opt.title); */ + /* for (int i = 0; i < opt.ing_n; i++) */ + /* printf("%s\n", opt.ing[i]); */ + /* if (opt.step_n) */ + /* printf("\n---\n\n"); */ + /* for (int i = 0; i < opt.step_n; i++) */ + /* printf("%s\n", opt.step[i]); */ + /* } */ + if (opt.new) { + recipe * r = new_recipe(); + char err[1000] = ""; + int rc = 0; + if (strcmp(opt.title, "")) - printf("@%s\n\n", opt.title); - for (int i = 0; i < opt.ing_n; i++) - printf("%s\n", opt.ing[i]); - if (opt.ing_n) - printf("\n---\n\n"); - for (int i = 0; i < opt.step_n; i++) - printf("%s\n", opt.step[i]); + r->title = strdup(opt.title); + for (int i = 0; i < opt.ing_n; i++) { + rc = parse_item(opt.ing[i], r, NULL, err); + if (rc) { + printf("ERROR: %s\n", err); + } + } + for (int i = 0; i < opt.step_n; i++) { + rc = parse_step(opt.step[i], r, err); + if (rc) { + printf("ERROR: %s\n", err); + } + } + + if (!rc) + torcp(r); + + free_recipe(r); } + return 0; } -- cgit v1.2.3