diff --git a/src/args.rs b/src/args.rs index f285a5a..0932ca0 100644 --- a/src/args.rs +++ b/src/args.rs @@ -21,7 +21,7 @@ pub struct Cli { #[arg(short, long, default_value_t = false)] pub exact: bool, - /// Print all matches in parent directories, not just the first + /// Print only the path containing the file, don't include the filename #[arg(short, long, default_value_t = false)] pub output_dir_only: bool, diff --git a/src/main.rs b/src/main.rs index ec436eb..72e8b96 100644 --- a/src/main.rs +++ b/src/main.rs @@ -29,7 +29,12 @@ fn main() { if (!cli.exact && file_name.contains(&cli.search.to_string())) || file_name == cli.search.to_string() { - let path = file.as_ref().unwrap().path(); + let path = if !cli.output_dir_only { + file.as_ref().unwrap().path() + } else { + directory.clone() + }; + let out = if cli.output_cannonical { fs::canonicalize(path) .expect("Encountered error while converting found item to canonical name")