Skip to content

Commit be30398

Browse files
authored
Don't print warning about missing root package in quiet mode. (#79)
There does not seem to be a way to avoid that warning if a workspace is used. So, allow the user to disable the warning by passing --quiet to cargo-xbuild.
1 parent df6db07 commit be30398

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

src/config.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ struct ParseConfig {
1919
}
2020

2121
impl Config {
22-
pub fn from_metadata(metadata: &cargo_metadata::Metadata) -> Result<Config> {
22+
pub fn from_metadata(metadata: &cargo_metadata::Metadata, quiet: bool) -> Result<Config> {
2323
let root_manifest = metadata.workspace_root.join("Cargo.toml");
2424
let root_package = metadata
2525
.packages
@@ -49,9 +49,11 @@ impl Config {
4949
//
5050
// So we can't read the config for such projects. To make this transparent to
5151
// the user, we print a warning.
52-
eprintln!(
53-
"WARNING: There is no root package to read the cargo-xbuild config from."
54-
);
52+
if !quiet {
53+
eprintln!(
54+
"WARNING: There is no root package to read the cargo-xbuild config from."
55+
);
56+
}
5557
// There is no config to read, so we use default options
5658
ParseConfig::default()
5759
}

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ pub fn build(args: Args, command_name: &str, crate_config: Option<Config>) -> Re
167167

168168
// Fall back to manifest if config not explicitly specified
169169
let crate_config = crate_config.map(Ok).unwrap_or_else(|| {
170-
Config::from_metadata(&metadata).map_err(|e| {
170+
Config::from_metadata(&metadata, args.quiet()).map_err(|e| {
171171
format!(
172172
"reading package.metadata.cargo-xbuild section failed: {}",
173173
e

0 commit comments

Comments
 (0)