Skip to content

Commit be353a7

Browse files
⚗️ Add bsdtar-compatible --block-size option to stdio command (#2566)
* feat(cli): Add bsdtar-compatible `-b` and `--block-size` options to stdio This commit introduces the `-b` and `--block-size` command-line options to the `pna experimental stdio` command for improved compatibility with bsdtar. These options are for interface compatibility only and are no-ops. They do not affect the runtime behavior of the command. When used, a warning is logged to inform the user that the option is ignored. - Added `block_size: Option<String>` to the `StdioCommand` struct. - Implemented a warning in `run_stdio` when the option is present. - Added integration tests to verify that both `-b` and `--block-size` are accepted and trigger the warning. * feat(cli): Add bsdtar-compatible `-b` and `--block-size` options to stdio This commit introduces the `-b` and `--block-size` command-line options to the `pna experimental stdio` command for improved compatibility with bsdtar. These options are for interface compatibility only and are no-ops. They do not affect the runtime behavior of the command. When used, a warning is logged to inform the user that the option is ignored. - Added `block_size: Option<usize>` to the `StdioCommand` struct. - Implemented a warning in `run_stdio` when the option is present. - Added integration tests to verify that both `-b` and `--block-size` are accepted and trigger the warning. - Hid the option from the help output as it's for compatibility only. --------- Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
1 parent 6ba0b28 commit be353a7

3 files changed

Lines changed: 58 additions & 0 deletions

File tree

cli/src/command/stdio.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,13 @@ pub(crate) struct StdioCommand {
487487
no_safe_writes: bool,
488488
#[arg(short = 'a', long = "auto-compress", hide = true)]
489489
auto_compress: bool,
490+
#[arg(
491+
short = 'b',
492+
long = "block-size",
493+
value_name = "blocksize",
494+
hide = true
495+
)]
496+
block_size: Option<usize>,
490497
#[arg(long, action = clap::ArgAction::Version, help = "Print version")]
491498
version: (),
492499
#[arg(long, action = clap::ArgAction::Help, help = "Print help")]
@@ -525,6 +532,11 @@ fn run_stdio(args: StdioCommand) -> anyhow::Result<()> {
525532
if args.auto_compress {
526533
log::warn!("Option '--auto-compress' is accepted for compatibility but will be ignored.");
527534
}
535+
if let Some(block_size) = &args.block_size {
536+
log::warn!(
537+
"Option '--block-size {block_size}' is accepted for compatibility but will be ignored."
538+
);
539+
}
528540
if args.create {
529541
run_create_archive(args)
530542
} else if args.extract {

cli/tests/cli/stdio.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
mod exclude_vcs;
22
mod files_from;
33
mod option_auto_compress;
4+
mod option_block_size;
45
mod option_check_links;
56
mod option_no_recursive;
67
mod option_update;
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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_block_size_option() {
9+
setup();
10+
let file = "stdio_block_size_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("--block-size")
18+
.arg("20")
19+
.arg(file)
20+
.assert()
21+
.success()
22+
.stderr(predicate::str::contains(
23+
"Option '--block-size 20' is accepted for compatibility but will be ignored.",
24+
));
25+
}
26+
27+
#[test]
28+
fn stdio_b_option() {
29+
setup();
30+
let file = "stdio_b_option.txt";
31+
fs::write(file, "").unwrap();
32+
33+
let mut cmd = cargo_bin_cmd!("pna");
34+
cmd.arg("experimental")
35+
.arg("stdio")
36+
.arg("-c")
37+
.arg("-b")
38+
.arg("20")
39+
.arg(file)
40+
.assert()
41+
.success()
42+
.stderr(predicate::str::contains(
43+
"Option '--block-size 20' is accepted for compatibility but will be ignored.",
44+
));
45+
}

0 commit comments

Comments
 (0)