use clap::{Args, Parser, Subcommand};
use std::path::PathBuf;
#[derive(Parser, Debug)]
#[command(
name = "lectern",
about = "Modern PHP dependency manager with Lectern.toml configuration",
version
)]
pub struct Cli {
#[arg(long, short = 'd', default_value = ".")]
pub working_dir: PathBuf,
#[arg(short = 'v', action = clap::ArgAction::Count)]
pub verbose: u8,
#[arg(short = 'q', long = "quiet")]
pub quiet: bool,
#[arg(short = 'n', long = "no-interaction")]
pub no_interaction: bool,
#[arg(long = "prefer-stable")]
pub prefer_stable: bool,
#[arg(long = "minimum-stability", default_value = "stable")]
pub minimum_stability: String,
#[arg(long = "memory-limit", default_value = "512")]
pub memory_limit: u32,
#[command(subcommand)]
pub command: Option<Commands>,
}
#[derive(Subcommand, Debug)]
pub enum Commands {
Install(InstallArgs),
Update(UpdateArgs),
Require(RequireArgs),
Remove(RemoveArgs),
Show(ShowArgs),
Autoload(DumpAutoloadArgs),
Search(SearchArgs),
Init(InitArgs),
Outdated,
Status,
Licenses,
Validate(ValidateArgs),
CreateProject(CreateProjectArgs),
DumpAutoload(DumpAutoloadArgs),
RunScript(RunScriptArgs),
Diagnose,
Archive(ArchiveArgs),
ClearCache(ClearCacheArgs),
Config(ConfigArgs),
Depends(DependsArgs),
Prohibits(ProhibitsArgs),
Browse(BrowseArgs),
Suggests,
Fund,
}
#[derive(Args, Debug)]
pub struct InstallArgs {
#[arg(long = "no-dev")]
pub no_dev: bool,
#[arg(long = "dry-run")]
pub dry_run: bool,
#[arg(long = "prefer-source")]
pub prefer_source: bool,
#[arg(long = "prefer-dist")]
pub prefer_dist: bool,
#[arg(long = "ignore-platform-reqs")]
pub ignore_platform_reqs: bool,
#[arg(long = "optimize-autoloader")]
pub optimize_autoloader: bool,
}
#[derive(Args, Debug)]
pub struct UpdateArgs {
pub packages: Vec<String>,
#[arg(long = "no-dev")]
pub no_dev: bool,
#[arg(long = "dry-run")]
pub dry_run: bool,
#[arg(long = "with-all-dependencies")]
pub with_all_dependencies: bool,
#[arg(long = "prefer-source")]
pub prefer_source: bool,
#[arg(long = "prefer-dist")]
pub prefer_dist: bool,
#[arg(long = "ignore-platform-reqs")]
pub ignore_platform_reqs: bool,
#[arg(long = "optimize-autoloader")]
pub optimize_autoloader: bool,
}
#[derive(Args, Debug)]
pub struct RequireArgs {
pub packages: Vec<String>,
#[arg(long = "dev")]
pub dev: bool,
#[arg(long = "dry-run")]
pub dry_run: bool,
#[arg(long = "no-update")]
pub no_update: bool,
#[arg(long = "update-with-dependencies")]
pub update_with_dependencies: bool,
#[arg(long = "ignore-platform-reqs")]
pub ignore_platform_reqs: bool,
}
#[derive(Args, Debug)]
pub struct RemoveArgs {
pub packages: Vec<String>,
#[arg(long = "dev")]
pub dev: bool,
#[arg(long = "dry-run")]
pub dry_run: bool,
#[arg(long = "no-update")]
pub no_update: bool,
#[arg(long = "update-with-dependencies")]
pub update_with_dependencies: bool,
}
#[derive(Args, Debug)]
pub struct ShowArgs {
pub package: Option<String>,
#[arg(long = "available")]
pub available: bool,
#[arg(long = "platform")]
pub platform: bool,
#[arg(long = "direct")]
pub direct: bool,
#[arg(long = "tree")]
pub tree: bool,
#[arg(long = "format", default_value = "table")]
pub format: String,
}
#[derive(Args, Debug)]
pub struct DumpAutoloadArgs {
#[arg(long = "optimize", short = 'o')]
pub optimize: bool,
#[arg(long = "classmap-authoritative")]
pub classmap_authoritative: bool,
#[arg(long = "apcu")]
pub apcu: bool,
#[arg(long = "no-dev")]
pub no_dev: bool,
}
#[derive(Args, Debug)]
pub struct SearchArgs {
pub terms: Vec<String>,
}
#[derive(Args, Debug)]
pub struct InitArgs {
#[arg(long = "name")]
pub name: Option<String>,
#[arg(long = "description")]
pub description: Option<String>,
#[arg(long = "author")]
pub author: Option<String>,
#[arg(long = "type", default_value = "library")]
pub project_type: String,
#[arg(long = "homepage")]
pub homepage: Option<String>,
#[arg(long = "require")]
pub require: bool,
#[arg(long = "require-dev")]
pub require_dev: bool,
#[arg(long = "stability")]
pub stability: Option<String>,
#[arg(long = "license")]
pub license: Option<String>,
#[arg(long = "repository")]
pub repository: Option<String>,
}
#[derive(Args, Debug)]
pub struct ValidateArgs {
#[arg(long = "no-check-publish")]
pub no_check_publish: bool,
#[arg(long = "with-dependencies")]
pub with_dependencies: bool,
#[arg(long = "strict")]
pub strict: bool,
}
#[derive(Args, Debug)]
pub struct CreateProjectArgs {
pub package: String,
pub directory: Option<String>,
pub version: Option<String>,
#[arg(long = "prefer-source")]
pub prefer_source: bool,
#[arg(long = "prefer-dist")]
pub prefer_dist: bool,
#[arg(long = "repository")]
pub repository: Option<String>,
#[arg(long = "dev")]
pub dev: bool,
#[arg(long = "no-install")]
pub no_install: bool,
#[arg(long = "ignore-platform-reqs")]
pub ignore_platform_reqs: bool,
}
#[derive(Args, Debug)]
pub struct RunScriptArgs {
pub script: String,
pub args: Vec<String>,
#[arg(long = "dev")]
pub dev: bool,
#[arg(long = "list")]
pub list: bool,
}
#[derive(Args, Debug)]
pub struct ArchiveArgs {
pub package: Option<String>,
pub version: Option<String>,
#[arg(long = "file")]
pub file: Option<String>,
#[arg(long = "dir")]
pub dir: Option<String>,
#[arg(long = "format", default_value = "tar")]
pub format: String,
}
#[derive(Args, Debug)]
pub struct ClearCacheArgs {
pub cache_type: Option<String>,
}
#[derive(Args, Debug)]
pub struct ConfigArgs {
pub key: Option<String>,
pub value: Option<String>,
#[arg(long = "list")]
pub list: bool,
#[arg(long = "global")]
pub global: bool,
#[arg(long = "unset")]
pub unset: bool,
}
#[derive(Args, Debug)]
pub struct DependsArgs {
pub package: String,
pub constraint: Option<String>,
#[arg(long = "recursive")]
pub recursive: bool,
#[arg(long = "tree")]
pub tree: bool,
}
#[derive(Args, Debug)]
pub struct ProhibitsArgs {
pub package: String,
pub constraint: Option<String>,
#[arg(long = "recursive")]
pub recursive: bool,
#[arg(long = "tree")]
pub tree: bool,
}
#[derive(Args, Debug)]
pub struct BrowseArgs {
pub package: String,
#[arg(long = "homepage")]
pub homepage: bool,
#[arg(long = "show")]
pub show: bool,
}