diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/cook.c | 41 |
1 files changed, 34 insertions, 7 deletions
@@ -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; } |