cargo-elfpak 0.2.0

Cargo subcommand for packaging a binary and its Linux runtime closure
Documentation
use clap::{Args, Parser, Subcommand};
use std::path::PathBuf;

#[derive(Debug, Parser)]
#[command(
    name = "cargo",
    bin_name = "cargo",
    version,
    about = "Package a Cargo binary and its Linux runtime closure"
)]
pub(crate) struct Cli {
    #[command(subcommand)]
    pub(crate) command: CargoCommand,

    /// Suppress all output except errors
    #[arg(short, long, global = true)]
    pub(crate) quiet: bool,

    /// Increase elfpak verbosity (-v, -vv)
    #[arg(short, long, global = true, action = clap::ArgAction::Count)]
    pub(crate) verbose: u8,
}

#[derive(Debug, Subcommand)]
pub(crate) enum CargoCommand {
    /// Package Cargo project binaries with elfpak
    Elfpak(ElfpakArgs),
}

#[derive(Debug, Args)]
pub(crate) struct ElfpakArgs {
    #[command(subcommand)]
    pub(crate) command: Command,
}

#[derive(Debug, Subcommand)]
pub(crate) enum Command {
    /// Build a Cargo binary and package its Linux runtime closure
    Bundle(CargoBundleArgs),
}

#[derive(Debug, Args)]
pub(crate) struct CargoBundleArgs {
    /// Select a package from the workspace
    #[arg(short = 'p', long = "package", value_name = "PACKAGE")]
    pub(crate) package: Option<String>,

    /// Select the binary target to package
    #[arg(long = "bin", value_name = "NAME")]
    pub(crate) bin: Option<String>,

    /// Build artifacts in release mode
    #[arg(long, conflicts_with = "profile")]
    pub(crate) release: bool,

    /// Build artifacts with the named Cargo profile
    #[arg(long, value_name = "NAME")]
    pub(crate) profile: Option<String>,

    /// Build for the target triple
    #[arg(long, value_name = "TRIPLE")]
    pub(crate) target: Option<String>,

    /// Directory for Cargo build artifacts
    #[arg(long, value_name = "DIR")]
    pub(crate) target_dir: Option<PathBuf>,

    /// Path to Cargo.toml
    #[arg(long, value_name = "PATH")]
    pub(crate) manifest_path: Option<PathBuf>,

    /// Space- or comma-separated features to activate
    #[arg(long, value_name = "FEATURES", action = clap::ArgAction::Append)]
    pub(crate) features: Vec<String>,

    /// Activate all available features
    #[arg(long)]
    pub(crate) all_features: bool,

    /// Do not activate the `default` feature
    #[arg(long)]
    pub(crate) no_default_features: bool,

    /// Require Cargo.lock to be up to date
    #[arg(long)]
    pub(crate) locked: bool,

    /// Run Cargo without accessing the network
    #[arg(long)]
    pub(crate) offline: bool,

    /// Require Cargo.lock and cached dependencies
    #[arg(long)]
    pub(crate) frozen: bool,

    #[command(flatten)]
    pub(crate) bundle: elfpak::BundleArgs,
}