fix --output-dir-only
This commit is contained in:
parent
01edabb232
commit
64a7834289
@ -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,
|
||||
|
||||
|
@ -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")
|
||||
|
Loading…
Reference in New Issue
Block a user