Skip to content

Commit c78bc84

Browse files
committed
address review feedback @thomastaylor312
1 parent 77d613e commit c78bc84

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

crates/wkg/src/main.rs

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -199,11 +199,11 @@ struct GetArgs {
199199
#[arg(long, value_enum, default_value = "auto")]
200200
format: Format,
201201

202-
/// Check that the got package matches the existing file at the output
203-
/// path. Output path will not be modified. Program exits with codes
204-
/// simmilar to diff(1): exits with 1 if there were differences, and 0
205-
/// means no differences.
206-
#[arg(long)]
202+
/// Check that the retrieved package matches the existing file at the
203+
/// output path. Output path will not be modified. Program exits with
204+
/// codes similar to diff(1): exits with 1 if there were differences, and
205+
/// 0 means no differences.
206+
#[arg(long, conflicts_with = "overwrite")]
207207
check: bool,
208208

209209
/// Overwrite any existing output file.
@@ -276,11 +276,6 @@ enum Format {
276276

277277
impl GetArgs {
278278
pub async fn run(self) -> anyhow::Result<()> {
279-
ensure!(
280-
!(self.overwrite && self.check),
281-
"Not allowed to specify both --check and --overwrite"
282-
);
283-
284279
let PackageSpec { package, version } = self.package_spec;
285280
let mut config = self.common.load_config().await?;
286281
if let Some(registry) = self.registry_args.registry.clone() {
@@ -385,12 +380,15 @@ impl GetArgs {
385380
};
386381

387382
if self.check {
388-
let existing = std::fs::read(&output_path)
383+
let existing = tokio::fs::read(&output_path)
384+
.await
389385
.with_context(|| format!("Failed to read {output_path:?}"))?;
390386
let latest = if let Some(wit) = wit {
391387
wit.into_bytes()
392388
} else {
393-
std::fs::read(&tmp_path).with_context(|| format!("Failed to read {tmp_path:?}"))?
389+
tokio::fs::read(&tmp_path)
390+
.await
391+
.with_context(|| format!("Failed to read {tmp_path:?}"))?
394392
};
395393
if existing != latest {
396394
anyhow::bail!("Differences between retrieved and {output_path:?}");
@@ -402,7 +400,8 @@ impl GetArgs {
402400
);
403401

404402
if let Some(wit) = wit {
405-
std::fs::write(&output_path, wit)
403+
tokio::fs::write(&output_path, wit)
404+
.await
406405
.with_context(|| format!("Failed to write WIT to {output_path:?}"))?
407406
} else {
408407
tmp_path

0 commit comments

Comments
 (0)