1
0
Fork 0
mirror of synced 2024-05-02 19:44:09 +12:00

Fixes default argument in -f option

This commit is contained in:
Rafał Mikrut 2020-09-29 09:27:31 +02:00
parent d34100461e
commit 3599bd3e20

View file

@ -144,7 +144,11 @@ fn main() {
#[allow(clippy::collapsible_if)]
if ArgumentsPair::has_command(&arguments, "-f") {
if !df.save_results_to_file(&ArgumentsPair::get_argument(&arguments, "-f", false)) {
let file_name = match ArgumentsPair::get_argument(&arguments, "-f", true).as_str() {
"" => "results.txt".to_string(),
t => t.to_string(),
};
if !df.save_results_to_file(file_name.as_str()) {
df.get_text_messages().print_messages();
process::exit(1);
}
@ -176,7 +180,11 @@ fn main() {
#[allow(clippy::collapsible_if)]
if ArgumentsPair::has_command(&arguments, "-f") {
if !ef.save_results_to_file(&ArgumentsPair::get_argument(&arguments, "-f", false)) {
let file_name = match ArgumentsPair::get_argument(&arguments, "-f", true).as_str() {
"" => "results.txt".to_string(),
t => t.to_string(),
};
if !ef.save_results_to_file(file_name.as_str()) {
ef.get_text_messages().print_messages();
process::exit(1);
}
@ -231,7 +239,11 @@ fn main() {
#[allow(clippy::collapsible_if)]
if ArgumentsPair::has_command(&arguments, "-f") {
if !bf.save_results_to_file(&ArgumentsPair::get_argument(&arguments, "-f", false)) {
let file_name = match ArgumentsPair::get_argument(&arguments, "-f", true).as_str() {
"" => "results.txt".to_string(),
t => t.to_string(),
};
if !bf.save_results_to_file(file_name.as_str()) {
bf.get_text_messages().print_messages();
process::exit(1);
}
@ -272,7 +284,11 @@ fn main() {
#[allow(clippy::collapsible_if)]
if ArgumentsPair::has_command(&arguments, "-f") {
if !yf.save_results_to_file(&ArgumentsPair::get_argument(&arguments, "-f", false)) {
let file_name = match ArgumentsPair::get_argument(&arguments, "-f", true).as_str() {
"" => "results.txt".to_string(),
t => t.to_string(),
};
if !yf.save_results_to_file(file_name.as_str()) {
yf.get_text_messages().print_messages();
process::exit(1);
}
@ -313,7 +329,11 @@ fn main() {
#[allow(clippy::collapsible_if)]
if ArgumentsPair::has_command(&arguments, "-f") {
if !tf.save_results_to_file(&ArgumentsPair::get_argument(&arguments, "-f", false)) {
let file_name = match ArgumentsPair::get_argument(&arguments, "-f", true).as_str() {
"" => "results.txt".to_string(),
t => t.to_string(),
};
if !tf.save_results_to_file(file_name.as_str()) {
tf.get_text_messages().print_messages();
process::exit(1);
}
@ -324,7 +344,7 @@ fn main() {
tf.get_text_messages().print_messages();
}
"--version" | "v" => {
"--version" | "--v" => {
println!("Czkawka CLI {}", CZKAWKA_VERSION);
process::exit(0);
}
@ -342,8 +362,8 @@ fn print_help() {
Main commands:
--h / --help - prints help, also works without any arguments
--d <-i directory_to_search> [-e exclude_directories = ""] [-k excluded_items = ""] [-s min_size = 1024] [-x allowed_extension = ""] [-l type_of_search = "hash"] [-o] [-f file_to_save = "results.txt"] [-delete = "aeo"] - search for duplicates files
--e <-i directory_to_search> [-e exclude_directories = ""] [-o] [-f file_to_save] [-delete] - option to find and delete empty folders
--b <-i directory_to_search> [-e exclude_directories = ""] [-k excluded_items = ""] [-p number_of_files = 50] [-x allowed_extension = ""] [-o] [-f file_to_save = "results.txt"]
--e <-i directory_to_search> [-e exclude_directories = ""] [-o] [-f file_to_save = "results.txt"] [-delete] - option to find and delete empty folders
--b <-i directory_to_search> [-e exclude_directories = ""] [-k excluded_items = ""] [-o] [-p number_of_files = 50] [-x allowed_extension = ""] [-f file_to_save = "results.txt"]
--y <-i directory_to_search> [-e exclude_directories = ""] [-k excluded_items = ""] [-o] [-f file_to_save = "results.txt"] [-delete] - search and delete empty files
--t <-i directory_to_search> [-e exclude_directories = ""] [-k excluded_items = ""] [-o] [-f file_to_save = "results.txt"] [-delete] - search for temporary files
--version / --v - prints program name and version
@ -351,14 +371,14 @@ fn print_help() {
Options:
-i directory_to_search - list of directories which should will be searched(absolute path)
-e exclude_directories - list of directories which will be excluded from search(absolute path)
-k excluded_items - list of excluded items which contains * wildcard(may be slow, so use exclude_directories where possible)
-o - this options prevents from recursive check of folders
-s min_size - minimum size of checked files in bytes, assigning bigger value may speed up searching.
-p number_of_files - number of showed the biggest files.
-x allowed_extension - list of checked files with provided extensions. There are also helpful macros which allow to easy use a typcal extensions like IMAGE("jpg,kra,gif,png,bmp,tiff,webp,hdr,svg"), TEXT, VIDEO or MUSIC.
-l type_of_search - allows to use fastest method which takes into account only size(SIZE), more accurate which takes into account hash of only first 1MB of file(HASHMB) or fully accurate(but the slowest solution) which check hash of all file(HASH).
-delete - delete found files, in duplicate finder by default remove all except the most oldest one but it can take arguments: aen(All except newest one), aeo(All except oldest one), on(Only one newest), oo(Only one oldest)
-f file_to_save - saves results to file
-k excluded_items - list of excluded items which contains * wildcard(may be slow, so use exclude_directories where possible)
-o - this options prevents from recursive check of folders
-s min_size - minimum size of checked files in bytes, assigning bigger value may speed up searching.
-p number_of_files - number of showed the biggest files.
-x allowed_extension - list of checked files with provided extensions. There are also helpful macros which allow to easy use a typcal extensions like IMAGE("jpg,kra,gif,png,bmp,tiff,webp,hdr,svg"), TEXT, VIDEO or MUSIC.
-l type_of_search - allows to use fastest method which takes into account only size(SIZE), more accurate which takes into account hash of only first 1MB of file(HASHMB) or fully accurate(but the slowest solution) which check hash of all file(HASH).
-f file_to_save - saves results to file
-delete - delete found files, in duplicate finder by default remove all files in group except the most oldest one but it can take arguments: aen(All except newest one), aeo(All except oldest one), on(Only one newest), oo(Only one oldest)
Usage example:
czkawka --d -i "/home/rafal/,/home/szczekacz" -e "/home/rafal/Pulpit,/home/rafal/Obrazy" -s 25 -x "7z,rar,IMAGE" -l "size" -f "results.txt" -delete "aeo"