use averse::{add, behold, plan, view};
use clap::{Parser, Subcommand};
#[derive(Parser)]
#[clap(author, version, about)]
struct Cli {
#[clap(short, long, default_value_t=String::from("./recipes"))]
recipe_dir: String,
#[clap(short, long, default_value_t=String::from("./plans"))]
plan_dir: String,
#[clap(subcommand)]
command: Commands,
}
#[derive(Subcommand)]
enum Commands {
Add,
View,
Plan {
#[clap(short, long)]
date: String,
},
Behold {
#[clap(short, long, default_value_t = 5)]
n_plans: usize,
},
}
fn main() {
let cli = Cli::parse();
if let Commands::Add {} = &cli.command {
add::add_recipe(&cli.recipe_dir).expect("Failed to add recipe");
} else if let Commands::View {} = &cli.command {
view::display_recipes(&cli.recipe_dir).expect("Failed to view recipes");
} else if let Commands::Plan { date } = &cli.command {
plan::plan_week(&cli.recipe_dir, &cli.plan_dir, date).expect("Planning failed");
} else if let Commands::Behold { n_plans } = &cli.command {
behold::display_plan(&cli.recipe_dir, &cli.plan_dir, n_plans)
.expect("Failed to Behold meal plan")
} else {
panic!("At the Disco")
}
}