Skip to content

Commit

Permalink
Default to 'this directory' for current path
Browse files Browse the repository at this point in the history
Instead of `.`, report the current working directory as 'this directory'.
Fixes #123.
  • Loading branch information
mjpieters authored and bnjbvr committed May 31, 2024
1 parent 77d207a commit 797aee6
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use anyhow::Context;
use rayon::prelude::*;
use std::path::Path;
use std::str::FromStr;
use std::{fs, path::PathBuf};
use std::{borrow::Cow, fs, path::PathBuf};

#[derive(Clone, Copy)]
pub(crate) enum UseCargoMetadata {
Expand Down Expand Up @@ -195,17 +195,22 @@ fn run_machete() -> anyhow::Result<bool> {
.collect::<Vec<_>>();

// Display all the results.
let location = match path.to_string_lossy() {
Cow::Borrowed(".") => Cow::from("this directory"),
pathstr => pathstr,
};

if results.is_empty() {
println!(
"cargo-machete didn't find any unused dependencies in {}. Good job!",
path.to_string_lossy()
location
);
continue;
}

println!(
"cargo-machete found the following unused dependencies in {}:",
path.to_string_lossy()
location
);
for (analysis, path) in results {
println!("{} -- {}:", analysis.package_name, path.to_string_lossy());
Expand Down

0 comments on commit 797aee6

Please sign in to comment.