use camino::Utf8PathBuf;
use clap::{Args, Parser, Subcommand};
use cooklang::Extensions;
use crate::{
collection, config_cmd, convert, edit, generate_completions, list, new, recipe, shopping_list,
units,
};
#[cfg(feature = "serve")]
use crate::serve;
#[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 = "read", visible_alias = "r")]
Recipe(recipe::ReadArgs),
#[command(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(config_cmd::ConfigArgs),
Collection(collection::CollectionArgs),
GenerateCompletions(generate_completions::GenerateCompletionsArgs),
New(new::NewArgs),
Edit(edit::EditArgs),
}
#[derive(Debug, Args)]
pub struct GlobalArgs {
#[arg(long, action = clap::ArgAction::Append, hide_short_help = true, global = true)]
pub units: Vec<Utf8PathBuf>,
#[arg(long, hide_short_help = true, global = true)]
pub override_units: bool,
#[arg(long, hide_short_help = true, global = true)]
pub no_default_units: bool,
#[arg(
long,
alias = "no-default-extensions",
group = "ext",
hide_short_help = true,
global = true
)]
pub no_extensions: bool,
#[arg(long, group = "ext", hide_short_help = true, global = true)]
pub all_extensions: bool,
#[arg(
long,
alias = "compat",
group = "ext",
hide_short_help = true,
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, hide_short_help = true, global = true, default_value_t = 10)]
pub max_depth: usize,
#[arg(long, hide_short_help = true, global = true)]
pub debug_trace: bool,
}