use clap::{Parser, Subcommand};
#[cfg(feature = "import")]
use crate::import;
#[cfg(feature = "lsp")]
use crate::lsp;
#[cfg(feature = "server")]
use crate::server;
#[cfg(feature = "self-update")]
use crate::update;
use crate::{build, completions, doctor, pantry, recipe, report, search, seed, shopping_list};
#[derive(Parser, Debug)]
#[command(
author,
version = concat!(env!("CARGO_PKG_VERSION"), " - in food we trust"),
about,
after_help = "Docs: https://cooklang.org/cli/"
)]
pub struct CliArgs {
#[arg(short = 'v', long = "verbose", action = clap::ArgAction::Count, global = true)]
pub verbosity: u8,
#[command(subcommand)]
pub command: Command,
}
#[derive(Debug, Subcommand)]
pub enum Command {
#[command(
alias = "r",
long_about = "Parse and display Cooklang recipe files with support for multiple output formats and scaling"
)]
Recipe(recipe::RecipeArgs),
#[command(
alias = "s",
long_about = "Run a web server to browse and interact with your recipe collection"
)]
#[cfg(feature = "server")]
Server(server::ServerArgs),
#[command(long_about = "Build artifacts (static website, etc.) from your recipe collection")]
Build(build::BuildArgs),
#[command(
visible_alias = "sl",
long_about = "Create shopping lists from one or more recipes with ingredient aggregation and categorization"
)]
ShoppingList(shopping_list::ShoppingListArgs),
#[command(long_about = "Populate a directory with example Cooklang recipes to get started")]
Seed(seed::SeedArgs),
#[command(
alias = "f",
long_about = "Search for recipes by ingredient, title, or any text content with relevance ranking"
)]
Search(search::SearchArgs),
#[command(
alias = "i",
long_about = "Import recipes from websites and automatically convert them to Cooklang format"
)]
#[cfg(feature = "import")]
Import(import::ImportArgs),
#[command(
alias = "rp",
long_about = "Generate custom reports and outputs from recipes using Jinja2 templates"
)]
Report(report::ReportArgs),
#[command(
long_about = "Check recipe collection for potential issues and suggest improvements"
)]
Doctor(doctor::DoctorArgs),
#[command(
alias = "p",
long_about = "Manage pantry inventory with full CRUD support and recipe-based analysis"
)]
Pantry(pantry::PantryArgs),
#[command(
long_about = "Start the Language Server Protocol server for Cooklang editor integration"
)]
#[cfg(feature = "lsp")]
Lsp(lsp::LspArgs),
#[cfg(feature = "sync")]
#[command(long_about = "Sign in to CookCloud via the OAuth 2.0 device-code flow")]
Login(crate::login::LoginArgs),
#[cfg(feature = "sync")]
#[command(long_about = "Sign out of CookCloud and delete the local session file")]
Logout(crate::logout::LogoutArgs),
#[command(
long_about = "Generate a shell completion script for bash, zsh, fish, PowerShell or elvish"
)]
Completions(completions::CompletionsArgs),
#[cfg(feature = "self-update")]
#[command(
alias = "u",
long_about = "Check for and install updates to CookCLI from GitHub releases"
)]
#[cfg(feature = "self-update")]
Update(update::UpdateArgs),
}