diff options
author | Anastasios Grammenos <anastasios.grammenos@noris.gr> | 2022-11-09 16:32:08 +0200 |
---|---|---|
committer | Anastasios Grammenos <anastasios.grammenos@noris.gr> | 2022-11-09 16:32:08 +0200 |
commit | a0bdc982adfea822a70849e779b2bb91285817ab (patch) | |
tree | 4394a7032834651689e55c00d720918893be9349 | |
parent | eb75ad1bb21826e482b3bc3251e83ac5a9121678 (diff) | |
download | foodtools-a0bdc982adfea822a70849e779b2bb91285817ab.tar.gz foodtools-a0bdc982adfea822a70849e779b2bb91285817ab.tar.bz2 foodtools-a0bdc982adfea822a70849e779b2bb91285817ab.zip |
testing new feature
-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; } |