feat(monorepo): add status type
This commit is contained in:
@@ -4,6 +4,7 @@ rust_library(
|
||||
name = "xatu_lib",
|
||||
crate_name = "xatu",
|
||||
srcs = ["xatu.rs"],
|
||||
deps = ["//src/status:status"],
|
||||
)
|
||||
|
||||
rust_binary(
|
||||
@@ -13,6 +14,7 @@ rust_binary(
|
||||
deps = [
|
||||
":xatu_lib",
|
||||
"//src/monorepo:monorepo",
|
||||
"//src/status:status",
|
||||
"//third_party/crates:clap",
|
||||
],
|
||||
)
|
||||
|
||||
@@ -11,6 +11,6 @@ name = "xatu"
|
||||
path = "xatu_main.rs"
|
||||
|
||||
[dependencies]
|
||||
anyhow = { workspace = true }
|
||||
clap = { workspace = true, features = ["derive"] }
|
||||
monorepo = { workspace = true }
|
||||
status = { workspace = true }
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
use std::path::PathBuf;
|
||||
|
||||
pub fn run(files: Vec<SourceFile>) -> Result<()> {
|
||||
pub fn run(files: Vec<SourceFile>) -> status::Result<()> {
|
||||
for file in files {
|
||||
println!("{}", file.path.display());
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub type Result<T> = std::result::Result<T, std::io::Error>;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct SourceFile {
|
||||
pub path: PathBuf,
|
||||
|
||||
@@ -25,7 +25,7 @@ fn is_excluded_dir(path: &Path) -> bool {
|
||||
})
|
||||
}
|
||||
|
||||
fn collect_source_files(path: &Path) -> xatu::Result<Vec<SourceFile>> {
|
||||
fn collect_source_files(path: &Path) -> status::Result<Vec<SourceFile>> {
|
||||
let metadata = std::fs::symlink_metadata(path)?;
|
||||
|
||||
if metadata.file_type().is_dir() {
|
||||
@@ -59,7 +59,7 @@ struct Args {
|
||||
paths: Vec<PathBuf>,
|
||||
}
|
||||
|
||||
fn main() -> xatu::Result<()> {
|
||||
fn main() -> status::Result<()> {
|
||||
let args = Args::parse();
|
||||
|
||||
let paths: Vec<PathBuf> = args
|
||||
@@ -71,7 +71,7 @@ fn main() -> xatu::Result<()> {
|
||||
let files: Vec<SourceFile> = paths
|
||||
.iter()
|
||||
.map(|path| collect_source_files(path))
|
||||
.collect::<xatu::Result<Vec<_>>>()?
|
||||
.collect::<status::Result<Vec<_>>>()?
|
||||
.into_iter()
|
||||
.flatten()
|
||||
.collect();
|
||||
|
||||
Reference in New Issue
Block a user