Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cli/no recursive option #1543

Merged
merged 2 commits into from
Feb 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions cli/src/command/append.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ use std::{fs::File, io, path::PathBuf};
group(ArgGroup::new("store-numeric-owner").args(["numeric_owner"]).requires("keep_permission")),
group(ArgGroup::new("user-flag").args(["numeric_owner", "uname"])),
group(ArgGroup::new("group-flag").args(["numeric_owner", "gname"])),
group(ArgGroup::new("recursive-flag").args(["recursive", "no_recursive"])),
)]
#[cfg_attr(windows, command(
group(ArgGroup::new("windows-unstable-keep-permission").args(["keep_permission"]).requires("unstable")),
Expand All @@ -49,6 +50,12 @@ pub(crate) struct AppendCommand {
help = "Add the directory to the archive recursively"
)]
pub(crate) recursive: bool,
#[arg(
long,
visible_alias = "no-recursion",
help = "Do not recursively add directories to the archives. This is the inverse option of --recursive"
)]
no_recursive: bool,
#[arg(long, help = "Archiving the directories")]
pub(crate) keep_dir: bool,
#[arg(
Expand Down
7 changes: 7 additions & 0 deletions cli/src/command/create.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ use std::{
group(ArgGroup::new("store-numeric-owner").args(["numeric_owner"]).requires("keep_permission")),
group(ArgGroup::new("user-flag").args(["numeric_owner", "uname"])),
group(ArgGroup::new("group-flag").args(["numeric_owner", "gname"])),
group(ArgGroup::new("recursive-flag").args(["recursive", "no_recursive"])),
)]
#[cfg_attr(windows, command(
group(ArgGroup::new("windows-unstable-keep-permission").args(["keep_permission"]).requires("unstable")),
Expand All @@ -55,6 +56,12 @@ pub(crate) struct CreateCommand {
help = "Add the directory to the archive recursively"
)]
pub(crate) recursive: bool,
#[arg(
long,
visible_alias = "no-recursion",
help = "Do not recursively add directories to the archives. This is the inverse option of --recursive"
)]
no_recursive: bool,
#[arg(long, help = "Overwrite file")]
pub(crate) overwrite: bool,
#[arg(long, help = "Archiving the directories")]
Expand Down
7 changes: 7 additions & 0 deletions cli/src/command/stdio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ use std::{
group(ArgGroup::new("path-transform").args(["substitutions", "transforms"])),
group(ArgGroup::new("user-flag").args(["numeric_owner", "uname"])),
group(ArgGroup::new("group-flag").args(["numeric_owner", "gname"])),
group(ArgGroup::new("recursive-flag").args(["recursive", "no_recursive"])),
)]
#[cfg_attr(windows, command(
group(ArgGroup::new("windows-unstable-keep-permission").args(["keep_permission"]).requires("unstable")),
Expand All @@ -55,6 +56,12 @@ pub(crate) struct StdioCommand {
help = "Add the directory to the archive recursively"
)]
recursive: bool,
#[arg(
long,
visible_alias = "no-recursion",
help = "Do not recursively add directories to the archives. This is the inverse option of --recursive"
)]
no_recursive: bool,
#[arg(long, help = "Overwrite file")]
overwrite: bool,
#[arg(long, help = "Archiving the directories")]
Expand Down
7 changes: 7 additions & 0 deletions cli/src/command/update.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ use std::{
group(ArgGroup::new("store-numeric-owner").args(["numeric_owner"]).requires("keep_permission")),
group(ArgGroup::new("user-flag").args(["numeric_owner", "uname"])),
group(ArgGroup::new("group-flag").args(["numeric_owner", "gname"])),
group(ArgGroup::new("recursive-flag").args(["recursive", "no_recursive"])),
)]
#[cfg_attr(windows, command(
group(ArgGroup::new("windows-unstable-keep-permission").args(["keep_permission"]).requires("unstable")),
Expand All @@ -61,6 +62,12 @@ pub(crate) struct UpdateCommand {
help = "Add the directory to the archive recursively"
)]
pub(crate) recursive: bool,
#[arg(
long,
visible_alias = "no-recursion",
help = "Do not recursively add directories to the archives. This is the inverse option of --recursive"
)]
no_recursive: bool,
#[arg(long, help = "Archiving the directories")]
pub(crate) keep_dir: bool,
#[arg(
Expand Down
1 change: 1 addition & 0 deletions cli/tests/cli/create.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
mod exclude;
mod no_recursive;
mod password_from_file;
mod password_hash;
mod substitution;
Expand Down
36 changes: 36 additions & 0 deletions cli/tests/cli/create/no_recursive.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
use crate::utils::{setup, TestResources};
use clap::Parser;
use portable_network_archive::{cli, command};
use std::fs;

#[test]
fn no_recursive() {
setup();
TestResources::extract_in("raw/", "no_recursive/in/").unwrap();
command::entry(cli::Cli::parse_from([
"pna",
"--quiet",
"c",
"no_recursive/no_recursive.pna",
"--overwrite",
"--no-recursive",
"no_recursive/in/",
]))
.unwrap();
assert!(fs::exists("no_recursive/no_recursive.pna").unwrap());

command::entry(cli::Cli::parse_from([
"pna",
"--quiet",
"x",
"no_recursive/no_recursive.pna",
"--overwrite",
"--out-dir",
"no_recursive/out/",
"--strip-components",
"2",
]))
.unwrap();
fs::create_dir_all("no_recursive/out/").unwrap();
assert_eq!(fs::read_dir("no_recursive/out/").unwrap().count(), 0);
}
Loading