Skip to content

Commit 40e57ee

Browse files
google-labs-jules[bot]ChanTsune
authored andcommitted
feat(cli): Add --auto-compress option to stdio subcommand
This commit adds the `--auto-compress` and `-a` options to the `stdio` subcommand to improve compatibility with `bsdtar`. The new options are accepted but have no effect, and a warning is logged to the console when they are used. An integration test has been added to verify the new behavior.
1 parent a62c4a5 commit 40e57ee

File tree

5 files changed

+69
-0
lines changed

5 files changed

+69
-0
lines changed

Cargo.lock

Lines changed: 19 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cli/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ criterion = { version = "0.7.0", default-features = false, features = ["cargo_be
7474

7575
[target.'cfg(not(target_family = "wasm"))'.dev-dependencies]
7676
assert_cmd = "2.1.1"
77+
predicates = "3.1.2"
7778

7879
[features]
7980
acl = [

cli/src/command/stdio.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -403,6 +403,8 @@ pub(crate) struct StdioCommand {
403403
safe_writes: bool,
404404
#[arg(long, hide = true)]
405405
no_safe_writes: bool,
406+
#[arg(short = 'a', long = "auto-compress", hide = true)]
407+
auto_compress: bool,
406408
#[arg(long, action = clap::ArgAction::Version, help = "Print version")]
407409
version: (),
408410
#[arg(long, action = clap::ArgAction::Help, help = "Print help")]
@@ -442,6 +444,9 @@ fn run_stdio(args: StdioCommand) -> anyhow::Result<()> {
442444
"Warning: Option '--no-safe-writes' is accepted for compatibility but will be ignored."
443445
);
444446
}
447+
if args.auto_compress {
448+
log::warn!("Option '--auto-compress' is accepted for compatibility but will be ignored.");
449+
}
445450
if args.create {
446451
run_create_archive(args)
447452
} else if args.extract {

cli/tests/cli/stdio.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
mod exclude_vcs;
22
mod files_from;
3+
mod option_auto_compress;
34
mod strip_components;
45
mod unlink_first;
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
#![cfg(not(target_family = "wasm"))]
2+
use crate::utils::setup;
3+
use assert_cmd::cargo::cargo_bin_cmd;
4+
use predicates::prelude::predicate;
5+
use std::fs;
6+
7+
#[test]
8+
fn stdio_auto_compress_option() {
9+
setup();
10+
let file = "stdio_auto_compress_option.txt";
11+
fs::write(file, "").unwrap();
12+
13+
let mut cmd = cargo_bin_cmd!("pna");
14+
cmd.arg("experimental")
15+
.arg("stdio")
16+
.arg("-c")
17+
.arg("--auto-compress")
18+
.arg(file)
19+
.assert()
20+
.success()
21+
.stderr(predicate::str::contains(
22+
"Option '--auto-compress' is accepted for compatibility but will be ignored.",
23+
));
24+
}
25+
26+
#[test]
27+
fn stdio_a_option() {
28+
setup();
29+
let file = "stdio_a_option.txt";
30+
fs::write(file, "").unwrap();
31+
32+
let mut cmd = cargo_bin_cmd!("pna");
33+
cmd.arg("experimental")
34+
.arg("stdio")
35+
.arg("-c")
36+
.arg("-a")
37+
.arg(file)
38+
.assert()
39+
.success()
40+
.stderr(predicate::str::contains(
41+
"Option '--auto-compress' is accepted for compatibility but will be ignored.",
42+
));
43+
}

0 commit comments

Comments
 (0)