watchexec/crates/project-origins/examples/find-origins.rs

20 lines
446 B
Rust
Raw Normal View History

2021-10-10 06:55:50 +02:00
use std::env::args;
use miette::{IntoDiagnostic, Result};
2022-06-15 05:25:05 +02:00
use project_origins::origins;
2021-10-10 06:55:50 +02:00
2022-06-15 05:25:05 +02:00
// Run with: `cargo run --example find-origins [PATH]`
2021-10-10 06:55:50 +02:00
#[tokio::main]
async fn main() -> Result<()> {
tracing_subscriber::fmt::init();
2022-06-15 05:25:05 +02:00
let first_arg = args().nth(1).unwrap_or_else(|| ".".to_string());
let path = dunce::canonicalize(first_arg).into_diagnostic()?;
2021-10-10 06:55:50 +02:00
for origin in origins(&path).await {
println!("{}", origin.display());
}
Ok(())
}