mirror of
https://github.com/ouch-org/ouch.git
synced 2025-07-19 16:10:53 +00:00
Merge branch 'main' into feat/lzma
This commit is contained in:
commit
deeeb80054
@ -56,8 +56,7 @@ pub fn check_mime_type(
|
|||||||
.ends_with(detected_format.compression_formats)
|
.ends_with(detected_format.compression_formats)
|
||||||
{
|
{
|
||||||
warning(format!(
|
warning(format!(
|
||||||
"The file extension: `{}` differ from the detected extension: `{}`",
|
"The file extension: `{outer_ext}` differ from the detected extension: `{detected_format}`"
|
||||||
outer_ext, detected_format
|
|
||||||
));
|
));
|
||||||
|
|
||||||
if !user_wants_to_continue(path, question_policy, QuestionAction::Decompression)? {
|
if !user_wants_to_continue(path, question_policy, QuestionAction::Decompression)? {
|
||||||
|
@ -303,7 +303,7 @@ pub fn decompress_file(options: DecompressOptions) -> crate::Result<()> {
|
|||||||
"Successfully decompressed archive in {}",
|
"Successfully decompressed archive in {}",
|
||||||
nice_directory_display(options.output_dir)
|
nice_directory_display(options.output_dir)
|
||||||
));
|
));
|
||||||
info_accessible(format!("Files unpacked: {}", files_unpacked));
|
info_accessible(format!("Files unpacked: {files_unpacked}"));
|
||||||
|
|
||||||
if !input_is_stdin && options.remove {
|
if !input_is_stdin && options.remove {
|
||||||
fs::remove_file(options.input_file_path)?;
|
fs::remove_file(options.input_file_path)?;
|
||||||
|
@ -139,8 +139,8 @@ impl FinalError {
|
|||||||
/// hint: Supported aliases are: tgz, tbz, tlz4, txz, tlzma, tsz, tzst, tlz
|
/// hint: Supported aliases are: tgz, tbz, tlz4, txz, tlzma, tsz, tzst, tlz
|
||||||
/// ```
|
/// ```
|
||||||
pub fn hint_all_supported_formats(self) -> Self {
|
pub fn hint_all_supported_formats(self) -> Self {
|
||||||
self.hint(format!("Supported extensions are: {}", PRETTY_SUPPORTED_EXTENSIONS))
|
self.hint(format!("Supported extensions are: {PRETTY_SUPPORTED_EXTENSIONS}"))
|
||||||
.hint(format!("Supported aliases are: {}", PRETTY_SUPPORTED_ALIASES))
|
.hint(format!("Supported aliases are: {PRETTY_SUPPORTED_ALIASES}"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -184,7 +184,7 @@ pub fn parse_format_flag(input: &OsStr) -> crate::Result<Vec<Extension>> {
|
|||||||
.map(|extension| {
|
.map(|extension| {
|
||||||
to_extension(extension.as_bytes()).ok_or_else(|| Error::InvalidFormatFlag {
|
to_extension(extension.as_bytes()).ok_or_else(|| Error::InvalidFormatFlag {
|
||||||
text: input.to_owned(),
|
text: input.to_owned(),
|
||||||
reason: format!("Unsupported extension '{}'", extension),
|
reason: format!("Unsupported extension '{extension}'"),
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.collect::<crate::Result<_>>()?;
|
.collect::<crate::Result<_>>()?;
|
||||||
|
@ -109,7 +109,7 @@ impl std::fmt::Display for Bytes {
|
|||||||
|
|
||||||
debug_assert!(num >= 0.0);
|
debug_assert!(num >= 0.0);
|
||||||
if num < 1_f64 {
|
if num < 1_f64 {
|
||||||
return write!(f, "{:>6.2} B", num);
|
return write!(f, "{num:>6.2} B");
|
||||||
}
|
}
|
||||||
|
|
||||||
let delimiter = 1000_f64;
|
let delimiter = 1000_f64;
|
||||||
|
@ -82,7 +82,7 @@ pub fn rename_or_increment_filename(path: &Path) -> PathBuf {
|
|||||||
let number = number_str.parse::<u32>().unwrap_or(0);
|
let number = number_str.parse::<u32>().unwrap_or(0);
|
||||||
format!("{}_{}", base, number + 1)
|
format!("{}_{}", base, number + 1)
|
||||||
}
|
}
|
||||||
_ => format!("{}_1", filename),
|
_ => format!("{filename}_1"),
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut new_path = parent.join(new_filename);
|
let mut new_path = parent.join(new_filename);
|
||||||
|
@ -187,7 +187,7 @@ impl<'a, T: Default> ChoicePrompt<'a, T> {
|
|||||||
|
|
||||||
#[cfg(not(feature = "allow_piped_choice"))]
|
#[cfg(not(feature = "allow_piped_choice"))]
|
||||||
if !stdin().is_terminal() {
|
if !stdin().is_terminal() {
|
||||||
eprintln!("{}", message);
|
eprintln!("{message}");
|
||||||
eprintln!("Pass --yes to proceed");
|
eprintln!("Pass --yes to proceed");
|
||||||
return Ok(T::default());
|
return Ok(T::default());
|
||||||
}
|
}
|
||||||
@ -222,10 +222,10 @@ impl<'a, T: Default> ChoicePrompt<'a, T> {
|
|||||||
.collect::<Vec<_>>()
|
.collect::<Vec<_>>()
|
||||||
.join("/");
|
.join("/");
|
||||||
|
|
||||||
format!("[{}]", choises)
|
format!("[{choises}]")
|
||||||
};
|
};
|
||||||
|
|
||||||
eprintln!("{} {}", message, choice_prompt);
|
eprintln!("{message} {choice_prompt}");
|
||||||
|
|
||||||
let mut answer = String::new();
|
let mut answer = String::new();
|
||||||
let bytes_read = stdin_lock.read_line(&mut answer)?;
|
let bytes_read = stdin_lock.read_line(&mut answer)?;
|
||||||
@ -284,7 +284,7 @@ impl<'a> Confirmation<'a> {
|
|||||||
|
|
||||||
#[cfg(not(feature = "allow_piped_choice"))]
|
#[cfg(not(feature = "allow_piped_choice"))]
|
||||||
if !stdin().is_terminal() {
|
if !stdin().is_terminal() {
|
||||||
eprintln!("{}", message);
|
eprintln!("{message}");
|
||||||
eprintln!("Pass --yes to proceed");
|
eprintln!("Pass --yes to proceed");
|
||||||
return Ok(false);
|
return Ok(false);
|
||||||
}
|
}
|
||||||
|
@ -173,7 +173,7 @@ fn single_file_stdin(
|
|||||||
fs::create_dir(before).unwrap();
|
fs::create_dir(before).unwrap();
|
||||||
let before_file = &before.join("file");
|
let before_file = &before.join("file");
|
||||||
let format = merge_extensions(&ext, &exts);
|
let format = merge_extensions(&ext, &exts);
|
||||||
let archive = &dir.join(format!("file.{}", format));
|
let archive = &dir.join(format!("file.{format}"));
|
||||||
let after = &dir.join("after");
|
let after = &dir.join("after");
|
||||||
write_random_content(
|
write_random_content(
|
||||||
&mut fs::File::create(before_file).unwrap(),
|
&mut fs::File::create(before_file).unwrap(),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user