mirror of
https://github.com/msfjarvis/gitice
synced 2025-08-14 20:57:01 +05:30
Add an initial search mechanism
Signed-off-by: Harsh Shandilya <me@msfjarvis.dev>
This commit is contained in:
parent
9a9c1ef656
commit
820fc6f1ab
1 changed files with 24 additions and 0 deletions
24
src/main.rs
24
src/main.rs
|
@ -1,2 +1,26 @@
|
|||
use std::path::Path;
|
||||
use walkdir::WalkDir;
|
||||
|
||||
fn main() {
|
||||
let dir = match std::env::args().nth(1) {
|
||||
Some(d) => d,
|
||||
None => {
|
||||
println!("Usage:\n gitice <dir>\n");
|
||||
return;
|
||||
},
|
||||
};
|
||||
let mut items: Vec<String> = Vec::new();
|
||||
for entry in WalkDir::new(dir)
|
||||
.into_iter()
|
||||
.filter_map(|e| e.ok())
|
||||
{
|
||||
if entry.file_type().is_dir() {
|
||||
let path = format!("{}/.git", entry.path().display());
|
||||
let git_dir = Path::new(&path);
|
||||
if git_dir.exists() {
|
||||
items.push(entry.path().to_string_lossy().to_string());
|
||||
}
|
||||
};
|
||||
}
|
||||
println!("{:#x?}", items);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue