Skip to content

Commit

Permalink
Merge pull request #108 from SpyrosRoum/migrate-to-clap
Browse files Browse the repository at this point in the history
Migrate from `oof` to `clap`!
  • Loading branch information
marcospb19 authored Oct 20, 2021
2 parents d533af2 + e17eb95 commit a46fa1f
Show file tree
Hide file tree
Showing 16 changed files with 277 additions and 857 deletions.
148 changes: 147 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ description = "A command-line utility for easily compressing and decompressing f
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
clap = "=3.0.0-beta.5" # Keep it pinned while in beta!
atty = "0.2.14"
once_cell = "1.8.0"
walkdir = "2.3.2"
strsim = "0.10.0"
bzip2 = "0.4.3"
libc = "0.2.103"
tar = "0.4.37"
Expand Down
10 changes: 7 additions & 3 deletions src/archive/tar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,23 @@ use tar;
use walkdir::WalkDir;

use crate::{
info, oof,
info,
utils::{self, Bytes},
};

pub fn unpack_archive(reader: Box<dyn Read>, output_folder: &Path, flags: &oof::Flags) -> crate::Result<Vec<PathBuf>> {
pub fn unpack_archive(
reader: Box<dyn Read>,
output_folder: &Path,
skip_questions_positively: Option<bool>,
) -> crate::Result<Vec<PathBuf>> {
let mut archive = tar::Archive::new(reader);

let mut files_unpacked = vec![];
for file in archive.entries()? {
let mut file = file?;

let file_path = output_folder.join(file.path()?);
if file_path.exists() && !utils::user_wants_to_overwrite(&file_path, flags)? {
if file_path.exists() && !utils::user_wants_to_overwrite(&file_path, skip_questions_positively)? {
continue;
}

Expand Down
12 changes: 8 additions & 4 deletions src/archive/zip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,18 @@ use walkdir::WalkDir;
use zip::{self, read::ZipFile, ZipArchive};

use crate::{
info, oof,
utils::{self, dir_is_empty, strip_cur_dir, Bytes},
info,
utils::{self, dir_is_empty,strip_cur_dir, Bytes},
};

use self::utf8::get_invalid_utf8_paths;

/// Unpacks the archive given by `archive` into the folder given by `into`.
pub fn unpack_archive<R>(mut archive: ZipArchive<R>, into: &Path, flags: &oof::Flags) -> crate::Result<Vec<PathBuf>>
pub fn unpack_archive<R>(
mut archive: ZipArchive<R>,
into: &Path,
skip_questions_positively: Option<bool>,
) -> crate::Result<Vec<PathBuf>>
where
R: Read + Seek,
{
Expand All @@ -30,7 +34,7 @@ where
};

let file_path = into.join(file_path);
if file_path.exists() && !utils::user_wants_to_overwrite(&file_path, flags)? {
if file_path.exists() && !utils::user_wants_to_overwrite(&file_path, skip_questions_positively)? {
continue;
}

Expand Down
Loading

0 comments on commit a46fa1f

Please sign in to comment.