blob: a34a912e5d3f539ffc4c128ad00ee0bcdf6c0284 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
use std::path::Path;
use crate::cli::Args;
fn is_cargo_toml(path: &Path) -> bool {
path.is_file() && (path.file_name().unwrap() == "Cargo.toml")
}
pub fn handle_path(path: &Path, iter: u8, cli: &Args) {
if is_cargo_toml(path) {
let abs_path = std::fs::canonicalize(path).unwrap();
println!("Clean: {}", abs_path.as_path().to_str().unwrap());
#[cfg(all(feature = "int-cargo", feature = "ext-cargo"))]
{
if cli.ext_cargo {
crate::cargo::clean_ext(abs_path.as_path(), cli);
} else {
crate::cargo::clean_int(abs_path.as_path(), cli).unwrap();
};
}
#[cfg(all(feature = "int-cargo", not(feature = "ext-cargo")))]
{
crate::cargo::clean_int(abs_path.as_path(), cli).unwrap();
}
#[cfg(all(feature = "ext-cargo", not(feature = "int-cargo")))]
{
crate::cargo::clean_ext(abs_path.as_path(), cli);
}
return;
};
if path.is_dir() {
if iter >= cli.level {
return;
};
let paths = std::fs::read_dir(path).unwrap();
for path in paths {
let p = path.unwrap();
handle_path(&p.path(), iter + 1, cli);
}
}
}
|