Crate clap_cargo

source ·
Expand description

clap-cargo: Re-usable CLI flags for cargo plugins

§Install

Add to your Cargo.toml:

[dependencies]
clap-cargo = "0.1"

§Examples

use clap::Parser;

// ...
#[derive(Debug, Parser)]
struct Cli {
    #[command(flatten)]
    manifest: clap_cargo::Manifest,
    #[command(flatten)]
    workspace: clap_cargo::Workspace,
    #[command(flatten)]
    features: clap_cargo::Features,
}

let cli = // ...
let mut metadata = cli.manifest.metadata();
cli.features.forward_metadata(&mut metadata);
let metadata = metadata.exec().unwrap();
let (selected, excluded) = cli.workspace.partition_packages(&metadata);

§Relevant crates

Other crates that might be useful for cargo plugins:

Modules§

Structs§

  • Cargo Feature Flags.
  • Cargo flag for selecting the relevant crate.
  • Cargo flags for selecting crates in a workspace.