use crate::prelude::*;
use clap::{Args, Parser, Subcommand};
#[derive(Parser, Debug)]
#[command(version, about)]
#[command(name = "cargo", bin_name = "cargo")]
pub enum TopLevel {
#[clap(name = "xcode-build-rs")]
XCodeBuild(XcodeBuild),
}
impl TopLevel {
fn inner(&self) -> &XcodeBuild {
match self {
TopLevel::XCodeBuild(inner) => inner,
}
}
}
#[derive(clap::Args, Debug)]
#[command(version, about)]
pub struct XcodeBuild {
#[clap(subcommand)]
mode: Mode,
#[clap(flatten)]
options: Options,
}
impl TopLevel {
pub fn options(&self) -> &Options {
&self.inner().options
}
pub fn mode(&self) -> &Mode {
&self.inner().mode
}
}
#[derive(Subcommand, Clone, Debug)]
pub enum Mode {
Xcode,
Test,
}
#[derive(Args, Debug)]
pub struct Options {
#[arg(long, alias = "colour")]
pub colour: bool,
#[arg(long, alias = "manifest-dir")]
manifest_dir: Utf8PathBuf,
}
impl Options {
pub fn manifest_path(&self) -> Utf8PathBuf {
self.manifest_dir.to_owned().join("Cargo.toml")
}
}