#!/usr/bin/env Rscript
args = commandArgs(trailingOnly = TRUE)
# To test:
# args <- NULL; args[1] <- "recipes/seasonal_oper.yml"


# execution: Rscript OperationalCS.R recipe.yml
# This code checks the recipe and builds and executes the workflow
print(args)
library(yaml)

recipe <- read_yaml(args[1])
recipe$filename <- args[1]

# Load required libraries
source("tools/libs.R")

# Create output folder and log:
logger <- prepare_outputs(recipe = recipe) 
folder <- logger$foldername
log_file <- logger$logname
logger <- logger$logger

# Checks:
verifications <- check_recipe(recipe, file = args[2], conf, logger) 
# Divide recipe into single verifications recipes:
total_recipes <- divide_recipe(recipe, verifications, folder, logger)
 
# Divide recipe into single verifications recipes:
total_recipes <- divide_recipe(recipe, verifications, folder, logger)
# Go to verification code: 
capture.output(source("modules/verifications.R"), 
               file = log_file, type ='message',
               append = TRUE)


