Skip to content

Commit 441a90b

Browse files
committed
Use #[derive(clap::ValueEnum)] to provide better help text on --describe argument
Signed-off-by: Sergey "Shnatsel" Davidoff <[email protected]>
1 parent 090e2c6 commit 441a90b

File tree

2 files changed

+4
-17
lines changed

2 files changed

+4
-17
lines changed

cargo-cyclonedx/src/cli.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ pub struct Args {
3434
#[clap(long = "format", short = 'f', value_name = "FORMAT")]
3535
pub format: Option<Format>,
3636

37-
/// What to describe in the SBOM: `crate`, `binaries` or `all-cargo-targets`
37+
// the ValueEnum derive provides ample help text
3838
#[clap(long = "describe")]
3939
pub describe: Option<Describe>,
4040

cargo-cyclonedx/src/config.rs

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -235,30 +235,17 @@ pub enum ParseMode {
235235
}
236236

237237
/// What does the SBOM describe?
238-
#[derive(Copy, Clone, Debug, Default, PartialEq, Eq)]
238+
#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, clap::ValueEnum)]
239239
pub enum Describe {
240-
/// The entire crate, with Cargo targets as subcomponents
240+
/// Describe the entire crate in a single SBOM file, with Cargo targets as subcomponents. (default)
241241
#[default]
242242
Crate,
243243
/// A separate SBOM is emitted for each binary (bin, cdylib) while all other targets are ignored
244244
Binaries,
245-
/// A separate SBOM is emitted for each target, including things that aren't directly executable (e.g rlib)
245+
/// A separate SBOM is emitted for each Cargo target, including things that aren't directly executable (e.g rlib)
246246
AllCargoTargets,
247247
}
248248

249-
impl FromStr for Describe {
250-
type Err = String;
251-
252-
fn from_str(s: &str) -> Result<Self, Self::Err> {
253-
match s {
254-
"crate" => Ok(Self::Crate),
255-
"binaries" => Ok(Self::Binaries),
256-
"all-cargo-targets" => Ok(Self::AllCargoTargets),
257-
_ => Err(format!("Expected bom or package, got `{}`", s)),
258-
}
259-
}
260-
}
261-
262249
#[cfg(test)]
263250
mod test {
264251
use super::*;

0 commit comments

Comments
 (0)