cargo-matrix 0.4.4

Run feature matrices against cargo commands that support feature lists
// Copyright (c) 2024 cargo-matrix developers
//
// Licensed under the Apache License, Version 2.0
// <LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0> or the MIT
// license <LICENSE-MIT or https://opensource.org/licenses/MIT>, at your
// option. All files in the project carrying such notice may not be copied,
// modified, or distributed except according to those terms.

use clap::{Args, Parser, crate_authors, crate_description, crate_version};
use getset::Getters;
use std::path::PathBuf;

#[derive(Debug, Parser)]
#[command(name = "cargo")]
#[command(bin_name = "cargo")]
pub(crate) enum Cargo {
    Matrix(MatrixArgs),
}

#[derive(Args, Debug, Getters)]
#[clap(
    author = crate_authors!(),
    version = crate_version!(),
    about = crate_description!(),
)]
#[command(version, about, long_about = None)]
#[getset(get = "pub(crate)")]
pub(crate) struct MatrixArgs {
    /// Choose the channel you wish to pull your config from
    #[clap(long, short)]
    channel: Option<String>,

    /// Perform a dry run and print output as if all the jobs succeeded.
    #[clap(long)]
    dry_run: bool,

    /// Specify an explict path to the manifest file
    #[arg(long)]
    manifest_path: Option<PathBuf>,

    /// Specify a specific package to run matrix against
    #[arg(long, short)]
    package: Option<String>,

    /// Split the workspace packages into 'n' chunks of packages
    #[arg(
        long,
        default_value_t = 1,
        requires = "chunk",
        help = "Split the workspace into n chunks, each chunk containing a roughly equal number of crates"
    )]
    num_chunks: usize,

    /// The chunk number to test, i.e. if `num_chunks` = 4, chunks can be 1, 2, 3, or 4.
    #[arg(
        long,
        default_value_t = 1,
        requires = "num_chunks",
        help = "Which chunk to test, indexed at 1"
    )]
    chunk: usize,

    /// The cargo command to run, followed by its arguments. Everything up to a
    /// `--` is the cargo subcommand and its flags (which must support `-p`,
    /// `--no-default-features`, and `-F`); everything after `--` is forwarded
    /// verbatim to the underlying command.
    #[clap(trailing_var_arg = true, allow_hyphen_values = true, required = true, num_args = 1..)]
    command: Vec<String>,
}