mecha10-cli 0.1.47

Mecha10 CLI tool
Documentation
//! Build command arguments

use clap::{Args, Subcommand, ValueEnum};

/// Build subcommands
#[derive(Subcommand, Debug)]
pub enum BuildCommand {
    /// Build robot nodes (runs on the robot hardware)
    Robot(BuildTargetArgs),

    /// Build remote nodes (runs in the cloud/remote server)
    Remote(BuildTargetArgs),
}

/// Version bump type
#[derive(Debug, Clone, Copy, ValueEnum)]
pub enum VersionBump {
    /// Bump patch version (0.1.0 -> 0.1.1)
    Patch,
    /// Bump minor version (0.1.0 -> 0.2.0)
    Minor,
    /// Bump major version (0.1.0 -> 1.0.0)
    Major,
}

/// Target architecture for Docker builds
#[derive(Debug, Clone, Copy, ValueEnum, Default)]
pub enum TargetArch {
    /// x86_64 (amd64) - Desktop, servers
    #[default]
    X86_64,
    /// aarch64 (arm64) - Raspberry Pi 4/5, Jetson, Apple Silicon
    Aarch64,
}

impl TargetArch {
    /// Get the Docker platform for this architecture
    pub fn docker_platform(&self) -> &'static str {
        match self {
            TargetArch::X86_64 => "linux/amd64",
            TargetArch::Aarch64 => "linux/arm64",
        }
    }

    /// Get the build arg value for TARGET_ARCH
    pub fn build_arg(&self) -> &'static str {
        match self {
            TargetArch::X86_64 => "x86_64",
            TargetArch::Aarch64 => "aarch64",
        }
    }
}

/// Common arguments for build targets
#[derive(Args, Debug)]
pub struct BuildTargetArgs {
    /// Build in release mode with optimizations
    #[arg(short, long)]
    pub release: bool,

    /// Optional target architecture for cross-compilation (cargo only)
    #[arg(short, long, conflicts_with = "docker")]
    pub target: Option<String>,

    /// Build using Docker for cross-compilation
    #[arg(short, long)]
    pub docker: bool,

    /// Target architecture for Docker builds
    #[arg(short, long, value_enum, default_value_t = TargetArch::X86_64, requires = "docker")]
    pub arch: TargetArch,

    /// Bump version before building (patch, minor, major)
    #[arg(long, value_enum, conflicts_with = "version")]
    pub bump: Option<VersionBump>,

    /// Set specific version before building (e.g., 1.2.3)
    #[arg(long, conflicts_with = "bump")]
    pub version: Option<String>,

    /// Build with dev environment (default is production for builds)
    #[arg(long)]
    pub dev: bool,
}