use clap::{Parser, Subcommand, ValueEnum};
use crate::runner::config::RendererBackend;
#[derive(Parser)]
#[command(
name = "cargo-telar",
bin_name = "cargo telar",
disable_help_subcommand = true
)]
pub(crate) struct Cli {
#[command(subcommand)]
pub(crate) command: Option<TelarCommand>,
}
#[derive(Subcommand)]
pub(crate) enum TelarCommand {
Dev(DevArgs),
Preview(PreviewArgs),
Build(BuildArgs),
Test(TestArgs),
Check(CheckArgs),
Doctor,
Fmt(FmtArgs),
}
#[derive(clap::Args)]
pub(crate) struct FmtArgs {
#[arg(long)]
pub(crate) check: bool,
pub(crate) paths: Vec<std::path::PathBuf>,
}
#[derive(clap::Args)]
pub(crate) struct CommonArgs {
#[arg(short = 'p', long)]
pub(crate) package: Option<String>,
#[arg(short = 'F', long, value_name = "FEATURES")]
pub(crate) features: Option<String>,
#[arg(long, value_enum, default_value = "desktop")]
pub(crate) target: Target,
#[arg(long, value_enum)]
pub(crate) backend: Option<RendererBackend>,
#[arg(last = true)]
pub(crate) cargo_args: Vec<String>,
}
#[derive(clap::Args)]
pub(crate) struct HotArgs {
#[command(flatten)]
pub(crate) common: CommonArgs,
#[arg(long)]
pub(crate) release: bool,
#[arg(long)]
pub(crate) no_hot_reload: bool,
}
#[derive(clap::Args)]
pub(crate) struct DevArgs {
#[command(flatten)]
pub(crate) hot: HotArgs,
#[arg(long, value_enum)]
pub(crate) devtools: Option<DevtoolsArg>,
}
#[derive(clap::Args)]
pub(crate) struct PreviewArgs {
#[command(flatten)]
pub(crate) hot: HotArgs,
#[arg(long, conflicts_with = "list")]
pub(crate) component: Option<String>,
#[arg(long)]
pub(crate) list: bool,
}
#[derive(clap::Args)]
pub(crate) struct CheckArgs {
#[command(flatten)]
pub(crate) common: CommonArgs,
#[arg(long)]
pub(crate) all_targets: bool,
}
#[derive(clap::Args)]
pub(crate) struct TestArgs {
#[command(flatten)]
pub(crate) common: CommonArgs,
#[arg(long)]
pub(crate) release: bool,
}
#[derive(clap::Args)]
pub(crate) struct BuildArgs {
#[command(flatten)]
pub(crate) common: CommonArgs,
#[arg(long, value_name = "FORMAT")]
pub(crate) format: Option<BuildFormat>,
}
#[derive(Clone, ValueEnum)]
pub(crate) enum Target {
Desktop,
Android,
}
#[derive(Clone, ValueEnum)]
pub(crate) enum DevtoolsArg {
On,
Off,
}
#[derive(Clone, ValueEnum)]
pub(crate) enum BuildFormat {
Appimage,
Deb,
Dmg,
Nsis,
Apk,
Dir,
}