Skip to content

Commit

Permalink
Minor style changes
Browse files Browse the repository at this point in the history
  • Loading branch information
sharkdp committed Sep 17, 2017
1 parent 2a3dd5b commit c1b8d1e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 20 deletions.
2 changes: 1 addition & 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
@@ -1,6 +1,6 @@
[package]
name = "fd-find"
version = "3.0.0"
version = "3.1.0"
authors = ["David Peter <[email protected]>"]
description = "fd is a simple, fast and user-friendly alternative to find."
homepage = "https://github.com/sharkdp/fd"
Expand Down
37 changes: 19 additions & 18 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,15 @@ enum PathDisplay {
Relative
}

/// The type of file to search for.
#[derive(Copy, Clone)]
enum FileType {
Any,
RegularFile,
Directory,
SymLink
}

/// Configuration options for *fd*.
struct FdOptions {
/// Determines whether the regex search is case-sensitive or case-insensitive.
Expand Down Expand Up @@ -82,18 +91,10 @@ struct FdOptions {
/// how to style different filetypes.
ls_colors: Option<LsColors>,

/// The type of file to search for. All files other than the specified type will be ignored.
file_type: FileType,
}

/// The type of file to search for. All files other than the specified type will be ignored.
#[derive(Copy, Clone)]
enum FileType {
Any,
RegularFile,
Directory,
SymLink,
}

/// The receiver thread can either be buffering results or directly streaming to the console.
enum ReceiverMode {
/// Receiver is still buffering in order to sort the results, if the search finishes fast
Expand Down Expand Up @@ -289,13 +290,13 @@ fn scan(root: &Path, pattern: Arc<Regex>, base: &Path, config: Arc<FdOptions>) {
match config.file_type {
FileType::Any => (),
FileType::RegularFile => if entry.file_type().map_or(false, |ft| !ft.is_file()) {
return ignore::WalkState::Continue;
return ignore::WalkState::Continue;
},
FileType::Directory => if entry.file_type().map_or(false, |ft| !ft.is_dir()) {
return ignore::WalkState::Continue;
return ignore::WalkState::Continue;
},
FileType::SymLink => if entry.file_type().map_or(false, |ft| !ft.is_symlink()) {
return ignore::WalkState::Continue;
return ignore::WalkState::Continue;
},
}

Expand Down Expand Up @@ -480,12 +481,12 @@ fn main() {
PathDisplay::Relative
},
ls_colors: ls_colors,
file_type: match matches.value_of("file-type") {
Some("f") | Some("file") => FileType::RegularFile,
Some("d") | Some("directory") => FileType::Directory,
Some("s") | Some("symlink") => FileType::SymLink,
_ => FileType::Any,
},
file_type: match matches.value_of("file-type") {
Some("f") | Some("file") => FileType::RegularFile,
Some("d") | Some("directory") => FileType::Directory,
Some("s") | Some("symlink") => FileType::SymLink,
_ => FileType::Any,
},
};

let root = Path::new(ROOT_DIR);
Expand Down

0 comments on commit c1b8d1e

Please sign in to comment.