Skip to content

Commit a1376c2

Browse files
committed
Add spec_version to CLI and config
Signed-off-by: Sergey "Shnatsel" Davidoff <[email protected]>
1 parent ef55a55 commit a1376c2

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

cargo-cyclonedx/src/cli.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use cargo_cyclonedx::{
88
platform::host_platform,
99
};
1010
use clap::{ArgAction, ArgGroup, Parser};
11+
use cyclonedx_bom::models::bom::SpecVersion;
1112
use std::collections::HashSet;
1213
use std::iter::FromIterator;
1314
use std::path;
@@ -95,6 +96,10 @@ Defaults to the host target, as printed by 'rustc -vV'"
9596
/// Add license names which will not be warned about when parsing them as a SPDX expression fails
9697
#[clap(long = "license-accept-named", action=ArgAction::Append)]
9798
pub license_accept_named: Vec<String>,
99+
100+
/// The CycloneDX specification version to output: `1.3` or `1.4`
101+
#[clap(long = "spec-version")]
102+
pub spec_version: Option<SpecVersion>,
98103
}
99104

100105
impl Args {
@@ -164,6 +169,7 @@ impl Args {
164169
});
165170

166171
let describe = self.describe.clone();
172+
let spec_version = self.spec_version.clone();
167173

168174
Ok(SbomConfig {
169175
format: self.format,
@@ -173,6 +179,7 @@ impl Args {
173179
target,
174180
license_parser,
175181
describe,
182+
spec_version,
176183
})
177184
}
178185
}

cargo-cyclonedx/src/config.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use cyclonedx_bom::models::bom::SpecVersion;
12
use serde::Deserialize;
23
use std::collections::HashSet;
34
use std::str::FromStr;
@@ -31,6 +32,7 @@ pub struct SbomConfig {
3132
pub target: Option<Target>,
3233
pub license_parser: Option<LicenseParserOptions>,
3334
pub describe: Option<Describe>,
35+
pub spec_version: Option<SpecVersion>,
3436
}
3537

3638
impl SbomConfig {
@@ -54,6 +56,10 @@ impl SbomConfig {
5456
.map(|other| self.license_parser.clone().unwrap_or_default().merge(other))
5557
.or_else(|| self.license_parser.clone()),
5658
describe: other.describe.clone().or_else(|| self.describe.clone()),
59+
spec_version: other
60+
.spec_version
61+
.clone()
62+
.or_else(|| self.spec_version.clone()),
5763
}
5864
}
5965

0 commit comments

Comments
 (0)