summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/cook.c41
1 files 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;
}