mirror of
https://github.com/jht5945/finding.git
synced 2025-12-29 06:00:04 +08:00
fill verbose
This commit is contained in:
19
src/main.rs
19
src/main.rs
@@ -64,7 +64,16 @@ fn get_term_width_message(message: &str, left: usize) -> String {
|
|||||||
fn find_huge_files(options: &Options, dir_path: &Path) {
|
fn find_huge_files(options: &Options, dir_path: &Path) {
|
||||||
walk_dir(&dir_path, &|_, _| (/* do not process error */), &|p| {
|
walk_dir(&dir_path, &|_, _| (/* do not process error */), &|p| {
|
||||||
match p.metadata() {
|
match p.metadata() {
|
||||||
Err(_) => (),
|
Err(err) => {
|
||||||
|
if options.verbose {
|
||||||
|
let p_str = p.to_str();
|
||||||
|
if p_str.is_some() {
|
||||||
|
print_lastline("");
|
||||||
|
print_message(MessageType::WARN, &format!("Read file {} meta failed: {}", p_str.unwrap(), err));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
},
|
||||||
Ok(metadata) => {
|
Ok(metadata) => {
|
||||||
let len = metadata.len();
|
let len = metadata.len();
|
||||||
if len >= options.parsed_huge_file_size {
|
if len >= options.parsed_huge_file_size {
|
||||||
@@ -133,6 +142,10 @@ fn match_lines(tag: &str, content: &String, options: &Options) {
|
|||||||
};
|
};
|
||||||
for ln in lines {
|
for ln in lines {
|
||||||
if options.filter_large_line && ln.len() as u64 >= options.parsed_large_line_size {
|
if options.filter_large_line && ln.len() as u64 >= options.parsed_large_line_size {
|
||||||
|
if options.verbose {
|
||||||
|
print_lastline("");
|
||||||
|
print_message(MessageType::INFO, &format!("Skip large line: {} bytes", ln.len()));
|
||||||
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
let matches = match ignore_case {
|
let matches = match ignore_case {
|
||||||
@@ -214,6 +227,10 @@ fn find_text_files(options: &Options, dir_path: &Path) {
|
|||||||
None => (),
|
None => (),
|
||||||
Some(p_str) => {
|
Some(p_str) => {
|
||||||
if (! options.scan_dot_git) && p_str.ends_with("/.git") {
|
if (! options.scan_dot_git) && p_str.ends_with("/.git") {
|
||||||
|
if options.verbose {
|
||||||
|
print_lastline("");
|
||||||
|
print_message(MessageType::INFO, &format!("Skip .git dir: {}", p_str));
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
print_lastline(&get_term_width_message(&format!("Scanning: {}", p_str), 10))
|
print_lastline(&get_term_width_message(&format!("Scanning: {}", p_str), 10))
|
||||||
|
|||||||
Reference in New Issue
Block a user