summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnastasios Grammenos <anastasios.grammenos@noris.gr>2022-11-09 16:32:08 +0200
committerAnastasios Grammenos <anastasios.grammenos@noris.gr>2022-11-09 16:32:08 +0200
commita0bdc982adfea822a70849e779b2bb91285817ab (patch)
tree4394a7032834651689e55c00d720918893be9349
parenteb75ad1bb21826e482b3bc3251e83ac5a9121678 (diff)
downloadfoodtools-a0bdc982adfea822a70849e779b2bb91285817ab.tar.gz
foodtools-a0bdc982adfea822a70849e779b2bb91285817ab.tar.bz2
foodtools-a0bdc982adfea822a70849e779b2bb91285817ab.zip
testing new feature
-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;
}