use camino::Utf8PathBuf;
use clap::{Args, Parser, Subcommand};
use cooklang::Extensions;
use crate::{convert, generate_completions, list, recipe, serve, shopping_list, units};
#[derive(Parser, Debug)]
#[command(
author,
version,
about,
after_help = "Docs: https://github.com/Zheoni/cooklang-chef/blob/main/docs/README.md"
)]
pub struct CliArgs {
#[command(subcommand)]
pub command: Command,
#[command(flatten)]
pub global_args: GlobalArgs,
}
#[derive(Debug, Subcommand, strum::Display)]
pub enum Command {
#[command(alias = "r")]
Recipe(recipe::RecipeArgs),
#[command(alias = "l", visible_alias = "ls")]
List(list::ListArgs),
#[cfg(feature = "serve")]
Serve(serve::ServeArgs),
#[command(visible_alias = "sl")]
ShoppingList(shopping_list::ShoppingListArgs),
Units(units::UnitsArgs),
#[command(visible_alias = "c")]
Convert(convert::ConvertArgs),
Config,
GenerateCompletions(generate_completions::GenerateCompletionsArgs),
}
#[derive(Debug, Args)]
pub struct GlobalArgs {
#[arg(long, action = clap::ArgAction::Append, global = true)]
pub units: Vec<Utf8PathBuf>,
#[arg(long, hide_short_help = true, global = true)]
pub no_default_units: bool,
#[arg(long, alias = "no-default-extensions", group = "ext", global = true)]
pub no_extensions: bool,
#[arg(long, group = "ext", global = true)]
pub all_extensions: bool,
#[arg(long, alias = "compat", group = "ext", global = true)]
pub compat_extensions: bool,
#[arg(
short,
long,
group = "ext",
value_parser = bitflags::parser::from_str::<Extensions>,
action = clap::ArgAction::Append,
global = true
)]
pub extensions: Vec<Extensions>,
#[arg(long, hide_short_help = true, global = true)]
pub warnings_as_errors: bool,
#[arg(
long,
hide_short_help = true,
conflicts_with = "warnings_as_errors",
global = true
)]
pub ignore_warnings: bool,
#[command(flatten)]
pub color: colorchoice_clap::Color,
#[arg(long, value_name = "PATH", value_hint = clap::ValueHint::DirPath, global = true)]
pub path: Option<Utf8PathBuf>,
#[arg(long, hide_short_help = true, global = true)]
pub no_recipe_ref_check: bool,
#[arg(long, global = true, default_value_t = 10)]
pub max_depth: usize,
#[arg(long, hide_short_help = true, global = true)]
pub debug_trace: bool,
}