mecha10-cli 4.2.15

Mecha10 CLI tool
Documentation
//! `mecha10 build-worker` arguments (LAB-5440/5442/5443/5450).
//!
//! This is the *server-side* half of "build via mecha10 dashboard": the CLI invocation
//! mecha10-api's Kestra dispatch sets as the `command` input of a `mecha10-deploy`
//! build-worker container (`docker/build-worker.Dockerfile`'s `ENTRYPOINT ["mecha10"]`, so
//! whatever this command's args look like is literally what mecha10-api must pass). It is not
//! meant to be run by an end user directly, hence `#[command(hide = true)]` on the `Commands`
//! variant - see `handlers::build_worker` for the full contract.
//!
//! A handful of inputs mecha10-api's Kestra dispatch already carries are deliberately **not**
//! CLI args here: `job_id`, `robot_id`, `api_url`, and the control-plane service `token` are
//! read straight from the `JOB_ID`/`ROBOT_ID`/`CONTROL_PLANE_URL`/`MECHA10_API_KEY` env vars
//! `run-container-job.yml` already injects automatically for every dispatched job, the same
//! vocabulary every other build-worker-style job in that template uses - see
//! `handlers::build_worker::WorkerEnv`. Everything else that varies per build-job becomes an
//! explicit flag below.
//!
//! Invocation shape a `mecha10-api` dispatch must produce:
//! ```text
//! mecha10 build-worker --target-platform <target_platform> --target-arch <target_arch> \
//!     [--source-url <source_url> --source-token <source_token>] \
//!     [--excluded-dirs <build_source_excluded_dirs>]
//! ```
//! `--source-url`/`--source-token` are only needed for the zip-upload source path; omit both
//! entirely for the GitHub path, where `run-container-job.yml` has already cloned the repo into
//! the working directory before `command` runs.

use clap::Args;

#[derive(Args, Debug, Clone)]
pub struct BuildWorkerArgs {
    /// Target platform to build for (e.g. "linux") - matches mecha10-api's build-job
    /// `target_platform` field.
    #[arg(long)]
    pub target_platform: String,

    /// Target architecture to build for (e.g. "aarch64", "x86_64") - matches mecha10-api's
    /// build-job `target_arch` field.
    #[arg(long)]
    pub target_arch: String,

    /// Zip-upload source path only: URL to fetch the project source zip from (mecha10-api's
    /// `source_url` build-job field). Fetched with `Authorization: Bearer <source-token>`.
    /// Required when the working directory is empty (no GitHub clone already present);
    /// ignored otherwise.
    #[arg(long)]
    pub source_url: Option<String>,

    /// Zip-upload source path only: bearer token for `--source-url` (mecha10-api's
    /// `source_token` build-job field).
    #[arg(long)]
    pub source_token: Option<String>,

    /// Comma-separated list of directories, relative to the project root, to remove before
    /// building (mecha10-api's `build_source_excluded_dirs` build-job field).
    #[arg(long)]
    pub excluded_dirs: Option<String>,
}