Compare commits

...

12 Commits
v0.1.0 ... main

23 changed files with 1100 additions and 987 deletions

View File

@ -20,14 +20,13 @@ jobs:
- name: Install Rust toolchain - name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable uses: dtolnay/rust-toolchain@stable
- name: Install dependencies - name: Install dependencies
run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev libwayland-dev libxkbcommon-dev run: sudo apt-get update; sudo apt-get install --no-install-recommends libasound2-dev libudev-dev libwayland-dev libxkbcommon-dev fd-find
- name: Populate target directory from cache - name: Populate target directory from cache
uses: Leafwing-Studios/cargo-cache@v2 uses: Leafwing-Studios/cargo-cache@v2
with: with:
sweep-cache: true sweep-cache: true
- name: Run tests - name: Run tests
run: | run: cargo test --locked --workspace --all-features --all-targets --release
cargo test --locked --workspace --all-features --all-targets
# Run clippy lints. # Run clippy lints.
clippy: clippy:
name: Clippy name: Clippy

23
.gitignore vendored
View File

@ -1 +1,22 @@
/target #--------------------------------------------------#
# The following was generated with gitignore.nvim: #
#--------------------------------------------------#
# Gitignore for the following technologies: Rust
# Generated by Cargo
# will have compiled files and executables
debug/
target/
# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
Cargo.lock
# These are backup files generated by rustfmt
**/*.rs.bk
# MSVC Windows builds of rustc generate these, which store debugging information
*.pdb
/benches/fixtures/*
!benches/fixtures/snapshot-2025-04-09_09-46-29.csv

802
Cargo.lock generated
View File

@ -1,802 +0,0 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 4
[[package]]
name = "addr2line"
version = "0.24.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dfbe277e56a376000877090da837660b4427aad530e3028d44e0bffe4f89a1c1"
dependencies = [
"gimli",
]
[[package]]
name = "adler2"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627"
[[package]]
name = "anstream"
version = "0.6.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8acc5369981196006228e28809f761875c0327210a891e941f4c683b3a99529b"
dependencies = [
"anstyle",
"anstyle-parse",
"anstyle-query",
"anstyle-wincon",
"colorchoice",
"is_terminal_polyfill",
"utf8parse",
]
[[package]]
name = "anstyle"
version = "1.0.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "55cc3b69f167a1ef2e161439aa98aed94e6028e5f9a59be9a6ffb47aef1651f9"
[[package]]
name = "anstyle-parse"
version = "0.2.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3b2d16507662817a6a20a9ea92df6652ee4f94f914589377d69f3b21bc5798a9"
dependencies = [
"utf8parse",
]
[[package]]
name = "anstyle-query"
version = "1.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "79947af37f4177cfead1110013d678905c37501914fba0efea834c3fe9a8d60c"
dependencies = [
"windows-sys 0.59.0",
]
[[package]]
name = "anstyle-wincon"
version = "3.0.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ca3534e77181a9cc07539ad51f2141fe32f6c3ffd4df76db8ad92346b003ae4e"
dependencies = [
"anstyle",
"once_cell",
"windows-sys 0.59.0",
]
[[package]]
name = "anyhow"
version = "1.0.97"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dcfed56ad506cb2c684a14971b8861fdc3baaaae314b9e5f9bb532cbe3ba7a4f"
[[package]]
name = "autocfg"
version = "1.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26"
[[package]]
name = "backtrace"
version = "0.3.74"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8d82cb332cdfaed17ae235a638438ac4d4839913cc2af585c3c6746e8f8bee1a"
dependencies = [
"addr2line",
"cfg-if",
"libc",
"miniz_oxide",
"object",
"rustc-demangle",
"windows-targets",
]
[[package]]
name = "bitflags"
version = "2.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c8214115b7bf84099f1309324e63141d4c5d7cc26862f97a0a857dbefe165bd"
[[package]]
name = "bytes"
version = "1.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d71b6127be86fdcfddb610f7182ac57211d4b18a3e9c82eb2d17662f2227ad6a"
[[package]]
name = "cfg-if"
version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "clap"
version = "4.5.32"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6088f3ae8c3608d19260cd7445411865a485688711b78b5be70d78cd96136f83"
dependencies = [
"clap_builder",
"clap_derive",
]
[[package]]
name = "clap_builder"
version = "4.5.32"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "22a7ef7f676155edfb82daa97f99441f3ebf4a58d5e32f295a56259f1b6facc8"
dependencies = [
"anstream",
"anstyle",
"clap_lex",
"strsim",
]
[[package]]
name = "clap_derive"
version = "4.5.32"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "09176aae279615badda0765c0c0b3f6ed53f4709118af73cf4655d85d1530cd7"
dependencies = [
"heck",
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "clap_lex"
version = "0.7.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f46ad14479a25103f283c0f10005961cf086d8dc42205bb44c46ac563475dca6"
[[package]]
name = "colorchoice"
version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990"
[[package]]
name = "either"
version = "1.15.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "48c757948c5ede0e46177b7add2e67155f70e33c07fea8284df6576da70b3719"
[[package]]
name = "env_home"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c7f84e12ccf0a7ddc17a6c41c93326024c42920d7ee630d04950e6926645c0fe"
[[package]]
name = "errno"
version = "0.3.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "33d852cb9b869c2a9b3df2f71a3074817f01e1844f839a144f5fcef059a4eb5d"
dependencies = [
"libc",
"windows-sys 0.59.0",
]
[[package]]
name = "futures"
version = "0.3.31"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "65bc07b1a8bc7c85c5f2e110c476c7389b4554ba72af57d8445ea63a576b0876"
dependencies = [
"futures-channel",
"futures-core",
"futures-executor",
"futures-io",
"futures-sink",
"futures-task",
"futures-util",
]
[[package]]
name = "futures-channel"
version = "0.3.31"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2dff15bf788c671c1934e366d07e30c1814a8ef514e1af724a602e8a2fbe1b10"
dependencies = [
"futures-core",
"futures-sink",
]
[[package]]
name = "futures-core"
version = "0.3.31"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e"
[[package]]
name = "futures-executor"
version = "0.3.31"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e28d1d997f585e54aebc3f97d39e72338912123a67330d723fdbb564d646c9f"
dependencies = [
"futures-core",
"futures-task",
"futures-util",
]
[[package]]
name = "futures-io"
version = "0.3.31"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6"
[[package]]
name = "futures-macro"
version = "0.3.31"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "futures-sink"
version = "0.3.31"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e575fab7d1e0dcb8d0c7bcf9a63ee213816ab51902e6d244a95819acacf1d4f7"
[[package]]
name = "futures-task"
version = "0.3.31"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f90f7dce0722e95104fcb095585910c0977252f286e354b5e3bd38902cd99988"
[[package]]
name = "futures-util"
version = "0.3.31"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81"
dependencies = [
"futures-channel",
"futures-core",
"futures-io",
"futures-macro",
"futures-sink",
"futures-task",
"memchr",
"pin-project-lite",
"pin-utils",
"slab",
]
[[package]]
name = "gimli"
version = "0.31.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f"
[[package]]
name = "heck"
version = "0.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
[[package]]
name = "is_terminal_polyfill"
version = "1.70.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7943c866cc5cd64cbc25b2e01621d07fa8eb2a1a23160ee81ce38704e97b8ecf"
[[package]]
name = "lazy_static"
version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe"
[[package]]
name = "libc"
version = "0.2.171"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c19937216e9d3aa9956d9bb8dfc0b0c8beb6058fc4f7a4dc4d850edf86a237d6"
[[package]]
name = "linux-raw-sys"
version = "0.4.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d26c52dbd32dccf2d10cac7725f8eae5296885fb5703b261f7d0a0739ec807ab"
[[package]]
name = "lock_api"
version = "0.4.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17"
dependencies = [
"autocfg",
"scopeguard",
]
[[package]]
name = "log"
version = "0.4.26"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "30bde2b3dc3671ae49d8e2e9f044c7c005836e7a023ee57cffa25ab82764bb9e"
[[package]]
name = "memchr"
version = "2.7.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3"
[[package]]
name = "miniz_oxide"
version = "0.8.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e3e04debbb59698c15bacbb6d93584a8c0ca9cc3213cb423d31f760d8843ce5"
dependencies = [
"adler2",
]
[[package]]
name = "mio"
version = "1.0.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2886843bf800fba2e3377cff24abf6379b4c4d5c6681eaf9ea5b0d15090450bd"
dependencies = [
"libc",
"wasi",
"windows-sys 0.52.0",
]
[[package]]
name = "nu-ansi-term"
version = "0.46.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "77a8165726e8236064dbb45459242600304b42a5ea24ee2948e18e023bf7ba84"
dependencies = [
"overload",
"winapi",
]
[[package]]
name = "object"
version = "0.36.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "62948e14d923ea95ea2c7c86c71013138b66525b86bdc08d2dcc262bdb497b87"
dependencies = [
"memchr",
]
[[package]]
name = "once_cell"
version = "1.21.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d75b0bedcc4fe52caa0e03d9f1151a323e4aa5e2d78ba3580400cd3c9e2bc4bc"
[[package]]
name = "overload"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b15813163c1d831bf4a13c3610c05c0d03b39feb07f7e09fa234dac9b15aaf39"
[[package]]
name = "parking_lot"
version = "0.12.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f1bf18183cf54e8d6059647fc3063646a1801cf30896933ec2311622cc4b9a27"
dependencies = [
"lock_api",
"parking_lot_core",
]
[[package]]
name = "parking_lot_core"
version = "0.9.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8"
dependencies = [
"cfg-if",
"libc",
"redox_syscall",
"smallvec",
"windows-targets",
]
[[package]]
name = "pin-project-lite"
version = "0.2.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b"
[[package]]
name = "pin-utils"
version = "0.1.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184"
[[package]]
name = "proc-macro2"
version = "1.0.94"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a31971752e70b8b2686d7e46ec17fb38dad4051d94024c88df49b667caea9c84"
dependencies = [
"unicode-ident",
]
[[package]]
name = "project-finder"
version = "0.1.0"
dependencies = [
"anyhow",
"clap",
"futures",
"thiserror",
"tokio",
"tracing",
"tracing-subscriber",
"which",
]
[[package]]
name = "quote"
version = "1.0.40"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d"
dependencies = [
"proc-macro2",
]
[[package]]
name = "redox_syscall"
version = "0.5.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0b8c0c260b63a8219631167be35e6a988e9554dbd323f8bd08439c8ed1302bd1"
dependencies = [
"bitflags",
]
[[package]]
name = "rustc-demangle"
version = "0.1.24"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f"
[[package]]
name = "rustix"
version = "0.38.44"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fdb5bc1ae2baa591800df16c9ca78619bf65c0488b41b96ccec5d11220d8c154"
dependencies = [
"bitflags",
"errno",
"libc",
"linux-raw-sys",
"windows-sys 0.59.0",
]
[[package]]
name = "scopeguard"
version = "1.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
[[package]]
name = "sharded-slab"
version = "0.1.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f40ca3c46823713e0d4209592e8d6e826aa57e928f09752619fc696c499637f6"
dependencies = [
"lazy_static",
]
[[package]]
name = "signal-hook-registry"
version = "1.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a9e9e0b4211b72e7b8b6e85c807d36c212bdb33ea8587f7569562a84df5465b1"
dependencies = [
"libc",
]
[[package]]
name = "slab"
version = "0.4.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f92a496fb766b417c996b9c5e57daf2f7ad3b0bebe1ccfca4856390e3d3bb67"
dependencies = [
"autocfg",
]
[[package]]
name = "smallvec"
version = "1.14.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7fcf8323ef1faaee30a44a340193b1ac6814fd9b7b4e88e9d4519a3e4abe1cfd"
[[package]]
name = "socket2"
version = "0.5.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c970269d99b64e60ec3bd6ad27270092a5394c4e309314b18ae3fe575695fbe8"
dependencies = [
"libc",
"windows-sys 0.52.0",
]
[[package]]
name = "strsim"
version = "0.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f"
[[package]]
name = "syn"
version = "2.0.100"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b09a44accad81e1ba1cd74a32461ba89dee89095ba17b32f5d03683b1b1fc2a0"
dependencies = [
"proc-macro2",
"quote",
"unicode-ident",
]
[[package]]
name = "thiserror"
version = "2.0.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "567b8a2dae586314f7be2a752ec7474332959c6460e02bde30d702a66d488708"
dependencies = [
"thiserror-impl",
]
[[package]]
name = "thiserror-impl"
version = "2.0.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7f7cf42b4507d8ea322120659672cf1b9dbb93f8f2d4ecfd6e51350ff5b17a1d"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "thread_local"
version = "1.1.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8b9ef9bad013ada3808854ceac7b46812a6465ba368859a37e2100283d2d719c"
dependencies = [
"cfg-if",
"once_cell",
]
[[package]]
name = "tokio"
version = "1.44.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f382da615b842244d4b8738c82ed1275e6c5dd90c459a30941cd07080b06c91a"
dependencies = [
"backtrace",
"bytes",
"libc",
"mio",
"parking_lot",
"pin-project-lite",
"signal-hook-registry",
"socket2",
"tokio-macros",
"windows-sys 0.52.0",
]
[[package]]
name = "tokio-macros"
version = "2.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6e06d43f1345a3bcd39f6a56dbb7dcab2ba47e68e8ac134855e7e2bdbaf8cab8"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "tracing"
version = "0.1.41"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "784e0ac535deb450455cbfa28a6f0df145ea1bb7ae51b821cf5e7927fdcfbdd0"
dependencies = [
"pin-project-lite",
"tracing-attributes",
"tracing-core",
]
[[package]]
name = "tracing-attributes"
version = "0.1.28"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "395ae124c09f9e6918a2310af6038fba074bcf474ac352496d5910dd59a2226d"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "tracing-core"
version = "0.1.33"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e672c95779cf947c5311f83787af4fa8fffd12fb27e4993211a84bdfd9610f9c"
dependencies = [
"once_cell",
"valuable",
]
[[package]]
name = "tracing-log"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ee855f1f400bd0e5c02d150ae5de3840039a3f54b025156404e34c23c03f47c3"
dependencies = [
"log",
"once_cell",
"tracing-core",
]
[[package]]
name = "tracing-subscriber"
version = "0.3.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e8189decb5ac0fa7bc8b96b7cb9b2701d60d48805aca84a238004d665fcc4008"
dependencies = [
"nu-ansi-term",
"sharded-slab",
"smallvec",
"thread_local",
"tracing-core",
"tracing-log",
]
[[package]]
name = "unicode-ident"
version = "1.0.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512"
[[package]]
name = "utf8parse"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "06abde3611657adf66d383f00b093d7faecc7fa57071cce2578660c9f1010821"
[[package]]
name = "valuable"
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ba73ea9cf16a25df0c8caa16c51acb937d5712a8429db78a3ee29d5dcacd3a65"
[[package]]
name = "wasi"
version = "0.11.0+wasi-snapshot-preview1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
[[package]]
name = "which"
version = "7.0.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2774c861e1f072b3aadc02f8ba886c26ad6321567ecc294c935434cad06f1283"
dependencies = [
"either",
"env_home",
"rustix",
"winsafe",
]
[[package]]
name = "winapi"
version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419"
dependencies = [
"winapi-i686-pc-windows-gnu",
"winapi-x86_64-pc-windows-gnu",
]
[[package]]
name = "winapi-i686-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
[[package]]
name = "winapi-x86_64-pc-windows-gnu"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
[[package]]
name = "windows-sys"
version = "0.52.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d"
dependencies = [
"windows-targets",
]
[[package]]
name = "windows-sys"
version = "0.59.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b"
dependencies = [
"windows-targets",
]
[[package]]
name = "windows-targets"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973"
dependencies = [
"windows_aarch64_gnullvm",
"windows_aarch64_msvc",
"windows_i686_gnu",
"windows_i686_gnullvm",
"windows_i686_msvc",
"windows_x86_64_gnu",
"windows_x86_64_gnullvm",
"windows_x86_64_msvc",
]
[[package]]
name = "windows_aarch64_gnullvm"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3"
[[package]]
name = "windows_aarch64_msvc"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469"
[[package]]
name = "windows_i686_gnu"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b"
[[package]]
name = "windows_i686_gnullvm"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66"
[[package]]
name = "windows_i686_msvc"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66"
[[package]]
name = "windows_x86_64_gnu"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78"
[[package]]
name = "windows_x86_64_gnullvm"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d"
[[package]]
name = "windows_x86_64_msvc"
version = "0.52.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
[[package]]
name = "winsafe"
version = "0.0.19"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d135d17ab770252ad95e9a872d365cf3090e3be864a34ab46f48555993efc904"

View File

@ -1,7 +1,7 @@
[package] [package]
name = "project-finder" name = "project-finder"
authors = ["Kristofers Solo <dev@kristofers.xyz>"] authors = ["Kristofers Solo <dev@kristofers.xyz>"]
version = "0.1.0" version = "0.1.2"
edition = "2024" edition = "2024"
description = "Fast project finder for developers" description = "Fast project finder for developers"
repository = "https://github.com/kristoferssolo/project-finder" repository = "https://github.com/kristoferssolo/project-finder"
@ -10,23 +10,50 @@ homepage = "https://github.com/kristoferssolo/project-finder"
license = "MIT OR Apache-2.0" license = "MIT OR Apache-2.0"
keywords = ["cli", "string", "text", "utility"] keywords = ["cli", "string", "text", "utility"]
categories = ["command-line-utilities"] categories = ["command-line-utilities"]
exclude = ["/.github", "/.gitignore", "/tests", "*.png", "*.md"] exclude = [
".github/",
".gitignore",
"tests/",
"benches/",
"scripts/",
"justifle",
"*.png",
"*.md",
]
readme = "README.md" readme = "README.md"
[dependencies] [dependencies]
anyhow = "1" anyhow = "1"
clap = { version = "4.5", features = ["derive"] } clap = { version = "4.5", features = ["derive"] }
futures = "0.3" futures = "0.3"
regex = "1.11"
thiserror = "2.0" thiserror = "2.0"
tokio = { version = "1", features = ["full"] } tokio = { version = "1.44", features = [
"fs",
"io-util",
"macros",
"process",
"rt",
"rt-multi-thread",
"sync",
] }
tracing = "0.1" tracing = "0.1"
tracing-subscriber = "0.3" tracing-subscriber = "0.3"
which = "7.0" which = "7.0"
[dev-dependencies] [dev-dependencies]
criterion = "0.5"
csv = "1.3"
serde = { version = "1", features = ["derive"] }
tempfile = "3.19"
[lints.clippy] [lints.clippy]
pedantic = "warn" pedantic = "warn"
nursery = "warn" nursery = "warn"
unwrap_used = "warn" unwrap_used = "warn"
expect_used = "warn" expect_used = "warn"
[[bench]]
name = "benchmark"
path = "benches/benchmark.rs"
harness = false

View File

@ -23,8 +23,6 @@ To use Project Finder, you need the following dependencies installed on your sys
* **fd:** A simple, fast, and user-friendly alternative to `find`. * **fd:** A simple, fast, and user-friendly alternative to `find`.
* Installation instructions: [https://github.com/sharkdp/fd#installation](https://github.com/sharkdp/fd#installation) * Installation instructions: [https://github.com/sharkdp/fd#installation](https://github.com/sharkdp/fd#installation)
* **ripgrep (rg):** A line-oriented search tool that recursively searches directories for a regex pattern.
* Installation instructions: [https://github.com/BurntSushi/ripgrep#installation](https://github.com/BurntSushi/ripgrep#installation)
These tools must be available in your system's PATH. These tools must be available in your system's PATH.

23
benches/benchmark.rs Normal file
View File

@ -0,0 +1,23 @@
mod common;
mod scenarios;
use common::setup::init_temp_dir;
use criterion::{Criterion, criterion_group, criterion_main};
use scenarios::{
basic::benchmark_basic, edge_cases::benchmark_edge_cases,
specific::benchmark_specific_scenarios,
};
use std::time::Duration;
criterion_group!(
name = benches;
config = {
let c = Criterion::default()
.sample_size(10)
.measurement_time(Duration::from_secs(30));
init_temp_dir();
c
};
targets = benchmark_basic, benchmark_edge_cases, benchmark_specific_scenarios
);
criterion_main!(benches);

View File

@ -0,0 +1,3 @@
pub fn default<T: Default>() -> T {
T::default()
}

4
benches/common/mod.rs Normal file
View File

@ -0,0 +1,4 @@
mod default;
pub mod setup;
pub mod utils;
pub use default::default;

201
benches/common/setup.rs Normal file
View File

@ -0,0 +1,201 @@
use crate::common::utils::BASE_DIR;
use anyhow;
use csv::Reader;
use regex::Regex;
use serde::{Deserialize, Deserializer};
use std::{
fmt::Display,
fs::{self, File, create_dir_all},
path::{Path, PathBuf},
str::FromStr,
sync::OnceLock,
};
use tempfile::TempDir;
pub static TEMP_DIR: OnceLock<TempDir> = OnceLock::new();
pub fn init_temp_dir() {
TEMP_DIR.get_or_init(|| setup_entries().expect("Failed to setup test directory"));
}
#[derive(Debug, Clone, Default)]
pub struct BenchParams {
pub depth: Option<usize>,
pub max_results: Option<usize>,
pub verbose: bool,
}
#[allow(dead_code)]
#[derive(Debug, Clone, Deserialize)]
struct FileEntry {
#[serde(rename = "type")]
entry_type: EntryType,
directory: PathBuf,
path: PathBuf,
#[serde(default)]
size: Size,
#[serde(default)]
modified: Modified,
#[serde(default)]
permissions: Permissions,
}
#[allow(dead_code)]
#[derive(Debug, Clone, Default, Deserialize)]
struct Size(#[serde(deserialize_with = "deserialize_u64_from_empty")] u64);
#[allow(dead_code)]
#[derive(Debug, Clone, Default, Deserialize)]
struct Modified(#[serde(deserialize_with = "deserialize_u64_from_empty")] u64);
#[allow(dead_code)]
#[derive(Debug, Clone, Deserialize)]
struct Permissions(#[serde(deserialize_with = "deserialize_u16_from_empty")] u16);
pub fn setup_entries() -> anyhow::Result<TempDir> {
let temp_dir = TempDir::new()?;
println!("Temporary directory: {:?}", temp_dir.path());
let fixtures_dir = PathBuf::from(BASE_DIR).join("benches/fixtures");
let snapshot_path = last_snaphow_file(&fixtures_dir)?;
let mut rdr = Reader::from_path(snapshot_path)?;
rdr.deserialize::<FileEntry>()
.for_each(|entry| match entry {
Ok(entry) => {
if let Err(e) = entry.to_tempfile(temp_dir.path()) {
eprintln!("Error processing entry: {}", e);
}
}
Err(e) => eprintln!("Failed to deserialize entry: {}", e),
});
Ok(temp_dir)
}
fn last_snaphow_file(dir: &Path) -> anyhow::Result<PathBuf> {
let re = Regex::new(r"^snapshot-(\d{4})-(\d{2})-(\d{2})_(\d{2})-(\d{2})-(\d{2})\.csv$")?;
let mut snapshots = fs::read_dir(dir)?
.filter_map(|entry| {
entry.ok().and_then(|entry| {
let file_name = entry.file_name();
if let Some(caps) = re.captures(&file_name.to_string_lossy()) {
let [y, m, d, h, min, s] = (1..=6)
.filter_map(|i| caps.get(i)?.as_str().parse().ok())
.collect::<Vec<u32>>()
.try_into()
.ok()?;
return Some(((y, m, d, h, min, s), entry.path()));
}
None
})
})
.collect::<Vec<_>>();
snapshots.sort_by_key(|(timestamp, _)| *timestamp);
snapshots
.last()
.map(|(_, path)| path.clone())
.ok_or_else(|| anyhow::anyhow!("No snapshot files found in directory"))
}
fn deserialize_u64_from_empty<'de, D>(deserializer: D) -> Result<u64, D::Error>
where
D: Deserializer<'de>,
{
let s = String::deserialize(deserializer)?;
if s.trim().is_empty() {
return Ok(0);
}
s.parse().map_err(serde::de::Error::custom)
}
fn deserialize_u16_from_empty<'de, D>(deserializer: D) -> Result<u16, D::Error>
where
D: Deserializer<'de>,
{
let s = String::deserialize(deserializer)?;
if s.trim().is_empty() {
return Ok(644);
}
s.parse().map_err(serde::de::Error::custom)
}
impl Default for Permissions {
fn default() -> Self {
Self(644)
}
}
#[derive(Debug, Clone, PartialEq)]
enum EntryType {
Dir,
File,
Symlink,
Other(String),
}
impl FromStr for EntryType {
type Err = String;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"dir" => Ok(Self::Dir),
"file" => Ok(Self::File),
"symlink" => Ok(Self::Symlink),
other if other.is_empty() => Err("Empty entry type".to_string()),
other => Ok(Self::Other(other.into())),
}
}
}
impl<'de> Deserialize<'de> for EntryType {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: Deserializer<'de>,
{
let s = String::deserialize(deserializer)?;
Self::from_str(&s).map_err(serde::de::Error::custom)
}
}
impl FileEntry {
fn to_tempfile(&self, base: &Path) -> anyhow::Result<()> {
let full_path = base.join(&self.path);
match self.entry_type {
EntryType::Dir => create_dir(&full_path),
EntryType::File => create_file(&full_path),
EntryType::Symlink => Ok(()),
EntryType::Other(_) => Ok(()),
}
}
}
fn create_file(path: &Path) -> anyhow::Result<()> {
if let Some(parent) = path.parent() {
create_dir(parent)?;
}
File::create(path)?;
Ok(())
}
fn create_dir(path: &Path) -> anyhow::Result<()> {
create_dir_all(path)?;
Ok(())
}
impl Display for BenchParams {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(
f,
"depth: {}, max: {}, verbose: {}",
self.depth.unwrap_or_default(),
self.max_results.unwrap_or_default(),
self.verbose
)
}
}

65
benches/common/utils.rs Normal file
View File

@ -0,0 +1,65 @@
use anyhow::anyhow;
use std::{
path::{Path, PathBuf},
process::Command,
};
use super::setup::BenchParams;
pub const BASE_DIR: &str = env!("CARGO_MANIFEST_DIR");
pub fn run_binary_with_args(path: &Path, params: &BenchParams) -> anyhow::Result<()> {
let binary_path = PathBuf::from(BASE_DIR).join("target/release/project-finder");
if !binary_path.exists() {
return Err(anyhow!(
"Binary not found at {}. Did you run `cargo build --release`?",
binary_path.display()
));
}
let mut cmd = Command::new(&binary_path);
// Add the path to search
cmd.arg(path);
if let Some(depth) = params.depth {
// Add depth parameter
cmd.arg("--depth").arg(depth.to_string());
}
// Add max_results parameter if not zero
if let Some(max_results) = params.max_results {
cmd.arg("--max-results").arg(max_results.to_string());
}
// Add verbose flag if true
if params.verbose {
cmd.arg("--verbose");
}
let output = cmd
.output()
.map_err(|e| anyhow!("Failed to execute binary {}: {}", binary_path.display(), e))?;
if !output.status.success() {
let stderr = String::from_utf8_lossy(&output.stderr);
return Err(anyhow!(
"Process failed with status: {}\nStderr: {}",
output.status,
stderr
));
}
Ok(())
}
#[allow(dead_code)]
pub fn create_deep_directory(_base: &Path, _depth: usize) -> anyhow::Result<()> {
todo!()
}
#[allow(dead_code)]
pub fn create_wide_directory(_base: &Path, _width: usize) -> anyhow::Result<()> {
todo!()
}

View File

@ -0,0 +1,187 @@
type,directory,path,size,modified,permissions
dir,"repos/project-finder",".git/",182,1744181103,755
file,"repos/project-finder",".git/COMMIT_EDITMSG",2587,1744179976,644
file,"repos/project-finder",".git/HEAD",21,1743401324,644
file,"repos/project-finder",".git/MERGE_RR",0,1744179976,644
file,"repos/project-finder",".git/config",290,1743418556,644
file,"repos/project-finder",".git/description",73,1743401321,644
dir,"repos/project-finder",".git/hooks/",556,1743401321,755
file,"repos/project-finder",".git/hooks/applypatch-msg.sample",478,1743401321,755
file,"repos/project-finder",".git/hooks/commit-msg.sample",896,1743401321,755
file,"repos/project-finder",".git/hooks/fsmonitor-watchman.sample",4726,1743401321,755
file,"repos/project-finder",".git/hooks/post-update.sample",189,1743401321,755
file,"repos/project-finder",".git/hooks/pre-applypatch.sample",424,1743401321,755
file,"repos/project-finder",".git/hooks/pre-commit.sample",1649,1743401321,755
file,"repos/project-finder",".git/hooks/pre-merge-commit.sample",416,1743401321,755
file,"repos/project-finder",".git/hooks/pre-push.sample",1374,1743401321,755
file,"repos/project-finder",".git/hooks/pre-rebase.sample",4898,1743401321,755
file,"repos/project-finder",".git/hooks/pre-receive.sample",544,1743401321,755
file,"repos/project-finder",".git/hooks/prepare-commit-msg.sample",1492,1743401321,755
file,"repos/project-finder",".git/hooks/push-to-checkout.sample",2783,1743401321,755
file,"repos/project-finder",".git/hooks/sendemail-validate.sample",2308,1743401321,755
file,"repos/project-finder",".git/hooks/update.sample",3650,1743401321,755
file,"repos/project-finder",".git/index",2533,1744181103,644
dir,"repos/project-finder",".git/info/",14,1743401321,755
file,"repos/project-finder",".git/info/exclude",240,1743401321,644
dir,"repos/project-finder",".git/logs/",16,1743401324,755
file,"repos/project-finder",".git/logs/HEAD",882,1744179976,644
dir,"repos/project-finder",".git/logs/refs/",24,1743401324,755
dir,"repos/project-finder",".git/logs/refs/heads/",8,1743401324,755
file,"repos/project-finder",".git/logs/refs/heads/main",882,1744179976,644
dir,"repos/project-finder",".git/logs/refs/remotes/",12,1743401324,755
dir,"repos/project-finder",".git/logs/refs/remotes/origin/",16,1743507200,755
file,"repos/project-finder",".git/logs/refs/remotes/origin/HEAD",193,1743401324,644
file,"repos/project-finder",".git/logs/refs/remotes/origin/main",453,1744179981,644
dir,"repos/project-finder",".git/objects/",212,1744181103,755
dir,"repos/project-finder",".git/objects/05/",76,1743506982,755
file,"repos/project-finder",".git/objects/05/42f055729f58c5dfb5ae0d0289f9c87c243e83",131,1743506982,644
dir,"repos/project-finder",".git/objects/0d/",76,1744179961,755
file,"repos/project-finder",".git/objects/0d/008191de032641fbd2a2eb545009a5e51d24f2",396,1744179961,644
dir,"repos/project-finder",".git/objects/16/",76,1744179976,755
file,"repos/project-finder",".git/objects/16/83728031be7aa16b7223d175a6ff3396816a01",176,1744179976,644
dir,"repos/project-finder",".git/objects/1a/",76,1743507195,755
file,"repos/project-finder",".git/objects/1a/0f34c996a2a963281fa5314e389e7b8d01a2fd",167,1743507195,644
dir,"repos/project-finder",".git/objects/1e/",76,1743506983,755
file,"repos/project-finder",".git/objects/1e/59450ca80c7690065858128ef76d91cef8b0b4",123,1744116033,644
dir,"repos/project-finder",".git/objects/23/",76,1743506982,755
file,"repos/project-finder",".git/objects/23/f5525c19fab1179c6e5cb3f7146ff71ab3039a",39,1743506982,644
dir,"repos/project-finder",".git/objects/2f/",76,1744116032,755
file,"repos/project-finder",".git/objects/2f/199553ab567645b7ee86a759c9871305352bbf",604,1744116032,644
dir,"repos/project-finder",".git/objects/33/",76,1743506982,755
file,"repos/project-finder",".git/objects/33/4c6b2c55b15aeee7fc2459f6326e34a8babc80",52,1743506982,644
dir,"repos/project-finder",".git/objects/38/",76,1743418561,755
file,"repos/project-finder",".git/objects/38/5a4bf20e6e7763d9b7d6e2dacc8ea5c8514ac9",178,1743418556,644
dir,"repos/project-finder",".git/objects/39/",76,1743506982,755
file,"repos/project-finder",".git/objects/39/fe23aee9ba630b582d4922a01639baeb847c8f",612,1743506982,644
dir,"repos/project-finder",".git/objects/3a/",76,1744179961,755
file,"repos/project-finder",".git/objects/3a/47d89d9c732761616407b9a72ec27254f732e7",144,1744179961,644
dir,"repos/project-finder",".git/objects/48/",76,1744179692,755
file,"repos/project-finder",".git/objects/48/8e44e088879549f2f76ae588a021836a950f9b",148,1744179692,644
dir,"repos/project-finder",".git/objects/4b/",76,1743418522,755
file,"repos/project-finder",".git/objects/4b/817742972348c1344cd17ef1e3180ffe8dfdf8",53,1743418518,644
dir,"repos/project-finder",".git/objects/51/",76,1744179687,755
file,"repos/project-finder",".git/objects/51/940dde9d3523626fd6f037287a483626037d02",745,1744179687,644
dir,"repos/project-finder",".git/objects/52/",76,1744179961,755
file,"repos/project-finder",".git/objects/52/b399c6d75a4675dae533a45d2bf6bb5696754f",123,1744179961,644
dir,"repos/project-finder",".git/objects/54/",76,1744179692,755
file,"repos/project-finder",".git/objects/54/d7c6bd1cedfc6e138df981848b0a1abdf6075c",144,1744179692,644
dir,"repos/project-finder",".git/objects/55/",152,1743506983,755
file,"repos/project-finder",".git/objects/55/f43dd7324ec6e153ee9eda5b6221593d285ed2",112,1743506983,644
file,"repos/project-finder",".git/objects/55/f65e27a46c473ea366ec1cddb8154690ae3839",1418,1743418513,644
dir,"repos/project-finder",".git/objects/5e/",76,1744116033,755
file,"repos/project-finder",".git/objects/5e/18e458c5b19b332a121b78c24f752e9ed8a173",396,1744116033,644
dir,"repos/project-finder",".git/objects/5f/",152,1744181103,755
file,"repos/project-finder",".git/objects/5f/1bde1904731b5da4ef66b7892742a9b5cff605",396,1744179692,644
file,"repos/project-finder",".git/objects/5f/cbdc69aba9e7a72a4796620a054ce7cadc229d",9500,1744181103,644
dir,"repos/project-finder",".git/objects/62/",76,1744116043,755
file,"repos/project-finder",".git/objects/62/0c274e546e03871325edcec22b808003dfee19",178,1744116043,644
dir,"repos/project-finder",".git/objects/67/",76,1743506982,755
file,"repos/project-finder",".git/objects/67/4646ab918e7762c7a08931bb61d1005306f6f8",717,1743506982,644
dir,"repos/project-finder",".git/objects/6a/",76,1743506982,755
file,"repos/project-finder",".git/objects/6a/fc6563569b79608daeaec721078a9aebb74ae1",646,1743506982,644
dir,"repos/project-finder",".git/objects/77/",76,1743504801,755
file,"repos/project-finder",".git/objects/77/c1ba4c0ddd5130cc87d2e7f204975fd9eeb67c",397,1743504801,644
dir,"repos/project-finder",".git/objects/78/",76,1744179961,755
file,"repos/project-finder",".git/objects/78/ace3398d9801bc0a80237ec2026318e38704c4",129,1744179961,644
dir,"repos/project-finder",".git/objects/7d/",76,1743506983,755
file,"repos/project-finder",".git/objects/7d/7780c4e28213f5ee76354ca15ad9416783d0b6",395,1743506983,644
dir,"repos/project-finder",".git/objects/82/",76,1744181103,755
file,"repos/project-finder",".git/objects/82/8a1b129c14280e9680c8a92b8ca78af2c145ac",630,1744181103,644
dir,"repos/project-finder",".git/objects/84/",76,1743418519,755
file,"repos/project-finder",".git/objects/84/10702d4b6ab3d3e966c871d209767c63992531",9498,1743418513,644
dir,"repos/project-finder",".git/objects/8a/",76,1744116033,755
file,"repos/project-finder",".git/objects/8a/ce0e8c46098e6b98bc48c716df1ff7ddaffde7",237,1744116033,644
dir,"repos/project-finder",".git/objects/8c/",76,1744179687,755
file,"repos/project-finder",".git/objects/8c/6fac4133881d7433de63ccc8d454c9d352c70c",60,1744179687,644
dir,"repos/project-finder",".git/objects/90/",76,1744179692,755
file,"repos/project-finder",".git/objects/90/382cf5e6d9313cecf70ff0350907749f3011fe",123,1744179692,644
dir,"repos/project-finder",".git/objects/91/",76,1743418522,755
file,"repos/project-finder",".git/objects/91/584a5d0c9844a31a42c855d5d97321af0a1970",57,1743418518,644
dir,"repos/project-finder",".git/objects/95/",76,1743418519,755
file,"repos/project-finder",".git/objects/95/01598d5b1e2c3835af01ac5878b3f485a0e8ce",599,1743504800,644
dir,"repos/project-finder",".git/objects/97/",76,1744179687,755
file,"repos/project-finder",".git/objects/97/ce6af6b7288bf6c0c35e92b8a60e288c06e4eb",57,1744179687,644
dir,"repos/project-finder",".git/objects/a1/",76,1744179687,755
file,"repos/project-finder",".git/objects/a1/7d7eb9ddb5d5ea8a19cd3c548a336663b7a945",474,1744179687,644
dir,"repos/project-finder",".git/objects/ae/",76,1744179687,755
file,"repos/project-finder",".git/objects/ae/92f72fbfb1062774e6a9591f267bdf6682d68b",1939,1744179687,644
dir,"repos/project-finder",".git/objects/b4/",76,1743418539,755
file,"repos/project-finder",".git/objects/b4/d0c988cbd01c9e231a085662930d31882626ec",396,1743418533,644
dir,"repos/project-finder",".git/objects/b5/",76,1743506982,755
file,"repos/project-finder",".git/objects/b5/6c2b2f4967e3f8d2bef13e76850e8613053ea4",124,1743506982,644
dir,"repos/project-finder",".git/objects/ba/",76,1744179961,755
file,"repos/project-finder",".git/objects/ba/b6a0d8843039159b276b7ebf633ec285995827",123,1744179961,644
dir,"repos/project-finder",".git/objects/bc/",76,1744179961,755
file,"repos/project-finder",".git/objects/bc/593dcfe2e70f8302bc92993ef25b963cfbba37",148,1744179961,644
dir,"repos/project-finder",".git/objects/c0/",76,1743506983,755
file,"repos/project-finder",".git/objects/c0/6f1f28de5dddabc5ef30e64ec419be7452c3d8",148,1743506983,644
dir,"repos/project-finder",".git/objects/c1/",76,1744179810,755
file,"repos/project-finder",".git/objects/c1/e568aa3fd7cdb7a8562bd4b8c517fe0062cb69",179,1744179810,644
dir,"repos/project-finder",".git/objects/c3/",76,1744179961,755
file,"repos/project-finder",".git/objects/c3/f760f421c863a263954f2eafb65539386385e7",461,1744179961,644
dir,"repos/project-finder",".git/objects/ca/",76,1743504800,755
file,"repos/project-finder",".git/objects/ca/510ddce02185e0ed0522c50bd29135357c5db8",1918,1743504800,644
dir,"repos/project-finder",".git/objects/cd/",76,1744181103,755
file,"repos/project-finder",".git/objects/cd/3057edd1d0279a4d20f0e052d615a5aeb45211",649,1744181103,644
dir,"repos/project-finder",".git/objects/d8/",76,1743504801,755
file,"repos/project-finder",".git/objects/d8/91e1a4d17a9436477a8512c917066216838091",57,1743504801,644
dir,"repos/project-finder",".git/objects/da/",76,1744179961,755
file,"repos/project-finder",".git/objects/da/48453b51006965ae0498bc731faae608a580dd",761,1744179961,644
dir,"repos/project-finder",".git/objects/df/",76,1743506982,755
file,"repos/project-finder",".git/objects/df/ec464726e5181577d1bc35fe1f7e35331d0ce2",297,1744116032,644
dir,"repos/project-finder",".git/objects/e8/",76,1743506982,755
file,"repos/project-finder",".git/objects/e8/55fe20e43e92e1bcd4cd5710b28e55a826bb30",1806,1743506982,644
dir,"repos/project-finder",".git/objects/ec/",76,1743418522,755
file,"repos/project-finder",".git/objects/ec/98fc190caf56fd498351832908feb4f181fc8a",396,1743418518,644
dir,"repos/project-finder",".git/objects/info/",0,1743401321,755
dir,"repos/project-finder",".git/objects/pack/",296,1743434535,755
file,"repos/project-finder",".git/objects/pack/pack-61ecb5aca089da0ef832eaa216764793abf0ec6b.idx",3396,1743401324,644
file,"repos/project-finder",".git/objects/pack/pack-61ecb5aca089da0ef832eaa216764793abf0ec6b.pack",34585,1744181103,644
file,"repos/project-finder",".git/objects/pack/pack-61ecb5aca089da0ef832eaa216764793abf0ec6b.rev",384,1743401324,644
file,"repos/project-finder",".git/packed-refs",228,1743401324,644
dir,"repos/project-finder",".git/refs/",32,1743401324,755
dir,"repos/project-finder",".git/refs/heads/",8,1744179976,755
file,"repos/project-finder",".git/refs/heads/main",41,1744179976,644
dir,"repos/project-finder",".git/refs/remotes/",12,1743401324,755
dir,"repos/project-finder",".git/refs/remotes/origin/",16,1744179981,755
file,"repos/project-finder",".git/refs/remotes/origin/HEAD",30,1743401324,644
file,"repos/project-finder",".git/refs/remotes/origin/main",41,1744179981,644
dir,"repos/project-finder",".git/refs/tags/",0,1743401324,755
dir,"repos/project-finder",".git/rr-cache/",0,1743418560,755
dir,"repos/project-finder",".github/",18,1743401324,755
dir,"repos/project-finder",".github/workflows/",34,1744181100,755
file,"repos/project-finder",".github/workflows/ci.yml",2645,1744181095,644
file,"repos/project-finder",".github/workflows/publish.yml",2941,1743401324,644
file,"repos/project-finder",".gitignore",8,1744181110,644
file,"repos/project-finder","Cargo.lock",32822,1744180164,644
file,"repos/project-finder","Cargo.toml",1205,1744180329,644
file,"repos/project-finder","LICENSE-APACHE",11357,1743401324,644
file,"repos/project-finder","LICENSE-MIT",1072,1743401324,644
file,"repos/project-finder","README.md",2987,1743401324,644
dir,"repos/project-finder","benches/",70,1743504888,755
file,"repos/project-finder","benches/benchmark.rs",603,1743507257,644
dir,"repos/project-finder","benches/common/",64,1744178507,755
file,"repos/project-finder","benches/common/default.rs",55,1744178557,644
file,"repos/project-finder","benches/common/mod.rs",69,1744178570,644
file,"repos/project-finder","benches/common/setup.rs",5438,1744179445,644
file,"repos/project-finder","benches/common/utils.rs",1646,1744179873,644
dir,"repos/project-finder","benches/fixtures/",64,1743402007,755
file,"repos/project-finder","benches/fixtures/snapshot-2025-03-31_09-20-03.csv",34307881,1743404688,644
dir,"repos/project-finder","benches/scenarios/",76,1743505197,755
file,"repos/project-finder","benches/scenarios/basic.rs",1070,1744179881,644
file,"repos/project-finder","benches/scenarios/edge_cases.rs",147,1744179825,644
file,"repos/project-finder","benches/scenarios/mod.rs",53,1743505198,644
file,"repos/project-finder","benches/scenarios/specific.rs",163,1744179828,644
file,"repos/project-finder","justfile",104,1743401324,644
dir,"repos/project-finder","scripts/",16,1743401324,755
file,"repos/project-finder","scripts/snapshot",6277,1743401324,755
dir,"repos/project-finder","src/",138,1743401324,755
file,"repos/project-finder","src/commands.rs",5888,1743401324,644
file,"repos/project-finder","src/config.rs",598,1743401324,644
file,"repos/project-finder","src/dependencies.rs",1255,1743401324,644
file,"repos/project-finder","src/errors.rs",592,1743401324,644
file,"repos/project-finder","src/finder.rs",12219,1743401324,644
file,"repos/project-finder","src/main.rs",1260,1744116028,644
file,"repos/project-finder","src/marker.rs",707,1743401324,644
dir,"repos/project-finder","tests/",12,1743401324,755
file,"repos/project-finder","tests/foo.rs",39,1743401324,644
1 type directory path size modified permissions
2 dir repos/project-finder .git/ 182 1744181103 755
3 file repos/project-finder .git/COMMIT_EDITMSG 2587 1744179976 644
4 file repos/project-finder .git/HEAD 21 1743401324 644
5 file repos/project-finder .git/MERGE_RR 0 1744179976 644
6 file repos/project-finder .git/config 290 1743418556 644
7 file repos/project-finder .git/description 73 1743401321 644
8 dir repos/project-finder .git/hooks/ 556 1743401321 755
9 file repos/project-finder .git/hooks/applypatch-msg.sample 478 1743401321 755
10 file repos/project-finder .git/hooks/commit-msg.sample 896 1743401321 755
11 file repos/project-finder .git/hooks/fsmonitor-watchman.sample 4726 1743401321 755
12 file repos/project-finder .git/hooks/post-update.sample 189 1743401321 755
13 file repos/project-finder .git/hooks/pre-applypatch.sample 424 1743401321 755
14 file repos/project-finder .git/hooks/pre-commit.sample 1649 1743401321 755
15 file repos/project-finder .git/hooks/pre-merge-commit.sample 416 1743401321 755
16 file repos/project-finder .git/hooks/pre-push.sample 1374 1743401321 755
17 file repos/project-finder .git/hooks/pre-rebase.sample 4898 1743401321 755
18 file repos/project-finder .git/hooks/pre-receive.sample 544 1743401321 755
19 file repos/project-finder .git/hooks/prepare-commit-msg.sample 1492 1743401321 755
20 file repos/project-finder .git/hooks/push-to-checkout.sample 2783 1743401321 755
21 file repos/project-finder .git/hooks/sendemail-validate.sample 2308 1743401321 755
22 file repos/project-finder .git/hooks/update.sample 3650 1743401321 755
23 file repos/project-finder .git/index 2533 1744181103 644
24 dir repos/project-finder .git/info/ 14 1743401321 755
25 file repos/project-finder .git/info/exclude 240 1743401321 644
26 dir repos/project-finder .git/logs/ 16 1743401324 755
27 file repos/project-finder .git/logs/HEAD 882 1744179976 644
28 dir repos/project-finder .git/logs/refs/ 24 1743401324 755
29 dir repos/project-finder .git/logs/refs/heads/ 8 1743401324 755
30 file repos/project-finder .git/logs/refs/heads/main 882 1744179976 644
31 dir repos/project-finder .git/logs/refs/remotes/ 12 1743401324 755
32 dir repos/project-finder .git/logs/refs/remotes/origin/ 16 1743507200 755
33 file repos/project-finder .git/logs/refs/remotes/origin/HEAD 193 1743401324 644
34 file repos/project-finder .git/logs/refs/remotes/origin/main 453 1744179981 644
35 dir repos/project-finder .git/objects/ 212 1744181103 755
36 dir repos/project-finder .git/objects/05/ 76 1743506982 755
37 file repos/project-finder .git/objects/05/42f055729f58c5dfb5ae0d0289f9c87c243e83 131 1743506982 644
38 dir repos/project-finder .git/objects/0d/ 76 1744179961 755
39 file repos/project-finder .git/objects/0d/008191de032641fbd2a2eb545009a5e51d24f2 396 1744179961 644
40 dir repos/project-finder .git/objects/16/ 76 1744179976 755
41 file repos/project-finder .git/objects/16/83728031be7aa16b7223d175a6ff3396816a01 176 1744179976 644
42 dir repos/project-finder .git/objects/1a/ 76 1743507195 755
43 file repos/project-finder .git/objects/1a/0f34c996a2a963281fa5314e389e7b8d01a2fd 167 1743507195 644
44 dir repos/project-finder .git/objects/1e/ 76 1743506983 755
45 file repos/project-finder .git/objects/1e/59450ca80c7690065858128ef76d91cef8b0b4 123 1744116033 644
46 dir repos/project-finder .git/objects/23/ 76 1743506982 755
47 file repos/project-finder .git/objects/23/f5525c19fab1179c6e5cb3f7146ff71ab3039a 39 1743506982 644
48 dir repos/project-finder .git/objects/2f/ 76 1744116032 755
49 file repos/project-finder .git/objects/2f/199553ab567645b7ee86a759c9871305352bbf 604 1744116032 644
50 dir repos/project-finder .git/objects/33/ 76 1743506982 755
51 file repos/project-finder .git/objects/33/4c6b2c55b15aeee7fc2459f6326e34a8babc80 52 1743506982 644
52 dir repos/project-finder .git/objects/38/ 76 1743418561 755
53 file repos/project-finder .git/objects/38/5a4bf20e6e7763d9b7d6e2dacc8ea5c8514ac9 178 1743418556 644
54 dir repos/project-finder .git/objects/39/ 76 1743506982 755
55 file repos/project-finder .git/objects/39/fe23aee9ba630b582d4922a01639baeb847c8f 612 1743506982 644
56 dir repos/project-finder .git/objects/3a/ 76 1744179961 755
57 file repos/project-finder .git/objects/3a/47d89d9c732761616407b9a72ec27254f732e7 144 1744179961 644
58 dir repos/project-finder .git/objects/48/ 76 1744179692 755
59 file repos/project-finder .git/objects/48/8e44e088879549f2f76ae588a021836a950f9b 148 1744179692 644
60 dir repos/project-finder .git/objects/4b/ 76 1743418522 755
61 file repos/project-finder .git/objects/4b/817742972348c1344cd17ef1e3180ffe8dfdf8 53 1743418518 644
62 dir repos/project-finder .git/objects/51/ 76 1744179687 755
63 file repos/project-finder .git/objects/51/940dde9d3523626fd6f037287a483626037d02 745 1744179687 644
64 dir repos/project-finder .git/objects/52/ 76 1744179961 755
65 file repos/project-finder .git/objects/52/b399c6d75a4675dae533a45d2bf6bb5696754f 123 1744179961 644
66 dir repos/project-finder .git/objects/54/ 76 1744179692 755
67 file repos/project-finder .git/objects/54/d7c6bd1cedfc6e138df981848b0a1abdf6075c 144 1744179692 644
68 dir repos/project-finder .git/objects/55/ 152 1743506983 755
69 file repos/project-finder .git/objects/55/f43dd7324ec6e153ee9eda5b6221593d285ed2 112 1743506983 644
70 file repos/project-finder .git/objects/55/f65e27a46c473ea366ec1cddb8154690ae3839 1418 1743418513 644
71 dir repos/project-finder .git/objects/5e/ 76 1744116033 755
72 file repos/project-finder .git/objects/5e/18e458c5b19b332a121b78c24f752e9ed8a173 396 1744116033 644
73 dir repos/project-finder .git/objects/5f/ 152 1744181103 755
74 file repos/project-finder .git/objects/5f/1bde1904731b5da4ef66b7892742a9b5cff605 396 1744179692 644
75 file repos/project-finder .git/objects/5f/cbdc69aba9e7a72a4796620a054ce7cadc229d 9500 1744181103 644
76 dir repos/project-finder .git/objects/62/ 76 1744116043 755
77 file repos/project-finder .git/objects/62/0c274e546e03871325edcec22b808003dfee19 178 1744116043 644
78 dir repos/project-finder .git/objects/67/ 76 1743506982 755
79 file repos/project-finder .git/objects/67/4646ab918e7762c7a08931bb61d1005306f6f8 717 1743506982 644
80 dir repos/project-finder .git/objects/6a/ 76 1743506982 755
81 file repos/project-finder .git/objects/6a/fc6563569b79608daeaec721078a9aebb74ae1 646 1743506982 644
82 dir repos/project-finder .git/objects/77/ 76 1743504801 755
83 file repos/project-finder .git/objects/77/c1ba4c0ddd5130cc87d2e7f204975fd9eeb67c 397 1743504801 644
84 dir repos/project-finder .git/objects/78/ 76 1744179961 755
85 file repos/project-finder .git/objects/78/ace3398d9801bc0a80237ec2026318e38704c4 129 1744179961 644
86 dir repos/project-finder .git/objects/7d/ 76 1743506983 755
87 file repos/project-finder .git/objects/7d/7780c4e28213f5ee76354ca15ad9416783d0b6 395 1743506983 644
88 dir repos/project-finder .git/objects/82/ 76 1744181103 755
89 file repos/project-finder .git/objects/82/8a1b129c14280e9680c8a92b8ca78af2c145ac 630 1744181103 644
90 dir repos/project-finder .git/objects/84/ 76 1743418519 755
91 file repos/project-finder .git/objects/84/10702d4b6ab3d3e966c871d209767c63992531 9498 1743418513 644
92 dir repos/project-finder .git/objects/8a/ 76 1744116033 755
93 file repos/project-finder .git/objects/8a/ce0e8c46098e6b98bc48c716df1ff7ddaffde7 237 1744116033 644
94 dir repos/project-finder .git/objects/8c/ 76 1744179687 755
95 file repos/project-finder .git/objects/8c/6fac4133881d7433de63ccc8d454c9d352c70c 60 1744179687 644
96 dir repos/project-finder .git/objects/90/ 76 1744179692 755
97 file repos/project-finder .git/objects/90/382cf5e6d9313cecf70ff0350907749f3011fe 123 1744179692 644
98 dir repos/project-finder .git/objects/91/ 76 1743418522 755
99 file repos/project-finder .git/objects/91/584a5d0c9844a31a42c855d5d97321af0a1970 57 1743418518 644
100 dir repos/project-finder .git/objects/95/ 76 1743418519 755
101 file repos/project-finder .git/objects/95/01598d5b1e2c3835af01ac5878b3f485a0e8ce 599 1743504800 644
102 dir repos/project-finder .git/objects/97/ 76 1744179687 755
103 file repos/project-finder .git/objects/97/ce6af6b7288bf6c0c35e92b8a60e288c06e4eb 57 1744179687 644
104 dir repos/project-finder .git/objects/a1/ 76 1744179687 755
105 file repos/project-finder .git/objects/a1/7d7eb9ddb5d5ea8a19cd3c548a336663b7a945 474 1744179687 644
106 dir repos/project-finder .git/objects/ae/ 76 1744179687 755
107 file repos/project-finder .git/objects/ae/92f72fbfb1062774e6a9591f267bdf6682d68b 1939 1744179687 644
108 dir repos/project-finder .git/objects/b4/ 76 1743418539 755
109 file repos/project-finder .git/objects/b4/d0c988cbd01c9e231a085662930d31882626ec 396 1743418533 644
110 dir repos/project-finder .git/objects/b5/ 76 1743506982 755
111 file repos/project-finder .git/objects/b5/6c2b2f4967e3f8d2bef13e76850e8613053ea4 124 1743506982 644
112 dir repos/project-finder .git/objects/ba/ 76 1744179961 755
113 file repos/project-finder .git/objects/ba/b6a0d8843039159b276b7ebf633ec285995827 123 1744179961 644
114 dir repos/project-finder .git/objects/bc/ 76 1744179961 755
115 file repos/project-finder .git/objects/bc/593dcfe2e70f8302bc92993ef25b963cfbba37 148 1744179961 644
116 dir repos/project-finder .git/objects/c0/ 76 1743506983 755
117 file repos/project-finder .git/objects/c0/6f1f28de5dddabc5ef30e64ec419be7452c3d8 148 1743506983 644
118 dir repos/project-finder .git/objects/c1/ 76 1744179810 755
119 file repos/project-finder .git/objects/c1/e568aa3fd7cdb7a8562bd4b8c517fe0062cb69 179 1744179810 644
120 dir repos/project-finder .git/objects/c3/ 76 1744179961 755
121 file repos/project-finder .git/objects/c3/f760f421c863a263954f2eafb65539386385e7 461 1744179961 644
122 dir repos/project-finder .git/objects/ca/ 76 1743504800 755
123 file repos/project-finder .git/objects/ca/510ddce02185e0ed0522c50bd29135357c5db8 1918 1743504800 644
124 dir repos/project-finder .git/objects/cd/ 76 1744181103 755
125 file repos/project-finder .git/objects/cd/3057edd1d0279a4d20f0e052d615a5aeb45211 649 1744181103 644
126 dir repos/project-finder .git/objects/d8/ 76 1743504801 755
127 file repos/project-finder .git/objects/d8/91e1a4d17a9436477a8512c917066216838091 57 1743504801 644
128 dir repos/project-finder .git/objects/da/ 76 1744179961 755
129 file repos/project-finder .git/objects/da/48453b51006965ae0498bc731faae608a580dd 761 1744179961 644
130 dir repos/project-finder .git/objects/df/ 76 1743506982 755
131 file repos/project-finder .git/objects/df/ec464726e5181577d1bc35fe1f7e35331d0ce2 297 1744116032 644
132 dir repos/project-finder .git/objects/e8/ 76 1743506982 755
133 file repos/project-finder .git/objects/e8/55fe20e43e92e1bcd4cd5710b28e55a826bb30 1806 1743506982 644
134 dir repos/project-finder .git/objects/ec/ 76 1743418522 755
135 file repos/project-finder .git/objects/ec/98fc190caf56fd498351832908feb4f181fc8a 396 1743418518 644
136 dir repos/project-finder .git/objects/info/ 0 1743401321 755
137 dir repos/project-finder .git/objects/pack/ 296 1743434535 755
138 file repos/project-finder .git/objects/pack/pack-61ecb5aca089da0ef832eaa216764793abf0ec6b.idx 3396 1743401324 644
139 file repos/project-finder .git/objects/pack/pack-61ecb5aca089da0ef832eaa216764793abf0ec6b.pack 34585 1744181103 644
140 file repos/project-finder .git/objects/pack/pack-61ecb5aca089da0ef832eaa216764793abf0ec6b.rev 384 1743401324 644
141 file repos/project-finder .git/packed-refs 228 1743401324 644
142 dir repos/project-finder .git/refs/ 32 1743401324 755
143 dir repos/project-finder .git/refs/heads/ 8 1744179976 755
144 file repos/project-finder .git/refs/heads/main 41 1744179976 644
145 dir repos/project-finder .git/refs/remotes/ 12 1743401324 755
146 dir repos/project-finder .git/refs/remotes/origin/ 16 1744179981 755
147 file repos/project-finder .git/refs/remotes/origin/HEAD 30 1743401324 644
148 file repos/project-finder .git/refs/remotes/origin/main 41 1744179981 644
149 dir repos/project-finder .git/refs/tags/ 0 1743401324 755
150 dir repos/project-finder .git/rr-cache/ 0 1743418560 755
151 dir repos/project-finder .github/ 18 1743401324 755
152 dir repos/project-finder .github/workflows/ 34 1744181100 755
153 file repos/project-finder .github/workflows/ci.yml 2645 1744181095 644
154 file repos/project-finder .github/workflows/publish.yml 2941 1743401324 644
155 file repos/project-finder .gitignore 8 1744181110 644
156 file repos/project-finder Cargo.lock 32822 1744180164 644
157 file repos/project-finder Cargo.toml 1205 1744180329 644
158 file repos/project-finder LICENSE-APACHE 11357 1743401324 644
159 file repos/project-finder LICENSE-MIT 1072 1743401324 644
160 file repos/project-finder README.md 2987 1743401324 644
161 dir repos/project-finder benches/ 70 1743504888 755
162 file repos/project-finder benches/benchmark.rs 603 1743507257 644
163 dir repos/project-finder benches/common/ 64 1744178507 755
164 file repos/project-finder benches/common/default.rs 55 1744178557 644
165 file repos/project-finder benches/common/mod.rs 69 1744178570 644
166 file repos/project-finder benches/common/setup.rs 5438 1744179445 644
167 file repos/project-finder benches/common/utils.rs 1646 1744179873 644
168 dir repos/project-finder benches/fixtures/ 64 1743402007 755
169 file repos/project-finder benches/fixtures/snapshot-2025-03-31_09-20-03.csv 34307881 1743404688 644
170 dir repos/project-finder benches/scenarios/ 76 1743505197 755
171 file repos/project-finder benches/scenarios/basic.rs 1070 1744179881 644
172 file repos/project-finder benches/scenarios/edge_cases.rs 147 1744179825 644
173 file repos/project-finder benches/scenarios/mod.rs 53 1743505198 644
174 file repos/project-finder benches/scenarios/specific.rs 163 1744179828 644
175 file repos/project-finder justfile 104 1743401324 644
176 dir repos/project-finder scripts/ 16 1743401324 755
177 file repos/project-finder scripts/snapshot 6277 1743401324 755
178 dir repos/project-finder src/ 138 1743401324 755
179 file repos/project-finder src/commands.rs 5888 1743401324 644
180 file repos/project-finder src/config.rs 598 1743401324 644
181 file repos/project-finder src/dependencies.rs 1255 1743401324 644
182 file repos/project-finder src/errors.rs 592 1743401324 644
183 file repos/project-finder src/finder.rs 12219 1743401324 644
184 file repos/project-finder src/main.rs 1260 1744116028 644
185 file repos/project-finder src/marker.rs 707 1743401324 644
186 dir repos/project-finder tests/ 12 1743401324 755
187 file repos/project-finder tests/foo.rs 39 1743401324 644

View File

@ -0,0 +1,43 @@
use crate::common::{
default,
setup::{BenchParams, TEMP_DIR, init_temp_dir},
utils::run_binary_with_args,
};
use criterion::{BenchmarkId, Criterion};
pub fn benchmark_basic(c: &mut Criterion) {
init_temp_dir();
let temp_dir = TEMP_DIR.get().unwrap().path();
let params = vec![
BenchParams {
depth: Some(1),
..Default::default()
},
BenchParams {
depth: Some(5),
..default()
},
BenchParams {
depth: Some(10),
..default()
},
BenchParams {
depth: Some(10),
max_results: Some(10),
..default()
},
];
let mut group = c.benchmark_group("basic_scenarios");
for (idx, param) in params.iter().enumerate() {
let id = BenchmarkId::new(format!("with_param_{idx}"), &param);
group.bench_with_input(id, &param, |b, param| {
b.iter(|| run_binary_with_args(temp_dir, param).expect("Failed to run binary"))
});
}
group.finish();
}

View File

@ -0,0 +1,6 @@
use criterion::Criterion;
pub fn benchmark_edge_cases(c: &mut Criterion) {
let group = c.benchmark_group("edge_cases");
group.finish();
}

3
benches/scenarios/mod.rs Normal file
View File

@ -0,0 +1,3 @@
pub mod basic;
pub mod edge_cases;
pub mod specific;

View File

@ -0,0 +1,6 @@
use criterion::Criterion;
pub fn benchmark_specific_scenarios(c: &mut Criterion) {
let group = c.benchmark_group("specific_scenarios");
group.finish();
}

2
justfile Normal file
View File

@ -0,0 +1,2 @@
snapshot +PATHS:
./scripts/snapshot -o benches/fixtures/"snapshot-{TIMESTAMP}.csv" -f csv {{PATHS}}

222
scripts/snapshot Executable file
View File

@ -0,0 +1,222 @@
#!/usr/bin/env bash
# Directory structure snapshot tool using fd (https://github.com/sharkdp/fd)
# Check if fd is installed
if ! command -v fd &>/dev/null; then
echo "Error: fd is not installed. Please install it first:"
echo " - Debian/Ubuntu: sudo apt install fd-find"
echo " - Fedora: sudo dnf install fd-find"
echo " - Arch: sudo pacman -S fd"
echo " - macOS: brew install fd"
echo " - Cargo: cargo install fd-find"
exit 1
fi
# Check if ripgrep is installed, fall back to grep if not
if command -v rg &>/dev/null; then
GREP_CMD="rg"
else
GREP_CMD="grep"
fi
# Usage information
usage() {
echo "Usage: $(basename "$0") [OPTIONS] DIRECTORY [DIRECTORY...]"
echo "Create a snapshot of directory structure(s) for benchmarking"
echo
echo "Options:"
echo " -o, --output FILE Output file (default: stdout)"
echo " Use {DATE} or {TIMESTAMP} for dynamic naming"
echo " -f, --format FORMAT Output format: csv or json (default: csv)"
echo " -h, --help Display this help message"
echo
echo "Examples:"
echo " $(basename "$0") ~/projects"
echo " $(basename "$0") -o snapshot.csv -f csv /path/to/dir"
echo " $(basename "$0") -o snapshot-{DATE}.csv ~/dir1 ~/dir2"
echo " $(basename "$0") -f json > snapshot.json"
exit 0
}
# Default values
DIRECTORIES=()
OUTPUT="/dev/stdout"
FORMAT="csv"
# Parse arguments
while [[ $# -gt 0 ]]; do
case "$1" in
-o | --output)
OUTPUT="$2"
shift 2
;;
-f | --format)
FORMAT="$2"
shift 2
;;
-h | --help)
usage
;;
*)
if [[ -d "$1" ]]; then
# Use cd + pwd instead of realpath for better performance
DIRECTORIES+=("$(cd "$1" && pwd)")
shift
else
echo "Error: Unknown option or invalid directory: $1"
usage
fi
;;
esac
done
# Check if at least one directory was provided
if [ ${#DIRECTORIES[@]} -eq 0 ]; then
DIRECTORIES=("$(pwd)")
fi
# Replace template variables in output filename
DATE_SHORT=$(date +"%Y%m%d")
TIMESTAMP=$(date +"%Y-%m-%d_%H-%M-%S")
OUTPUT="${OUTPUT//\{DATE\}/$DATE_SHORT}"
OUTPUT="${OUTPUT//\{TIMESTAMP\}/$TIMESTAMP}"
# Ensure the output directory exists
OUTPUT_DIR=$(dirname "$OUTPUT")
[ "$OUTPUT_DIR" != "/dev" ] && mkdir -p "$OUTPUT_DIR"
# Timestamp for the snapshot
TIMESTAMP_HUMAN=$(date +"%Y-%m-%d %H:%M:%S")
EPOCH=$(date +%s)
# Create a temporary file for processing
TEMP_DATA=$(mktemp)
trap 'rm -f "$TEMP_DATA"' EXIT
# Collect data from all directories more efficiently
for DIR in "${DIRECTORIES[@]}"; do
# Process entries directly without the separate xargs+stat calls
fd . "$DIR" -H -t f -t d -t l -0 | perl -0 -ne '
chomp;
$dir = "'$DIR'";
$path = $_;
if (-f $path) { $type = "file"; }
elsif (-d $path) { $type = "dir"; }
elsif (-l $path) { $type = "symlink"; }
else { $type = "other"; }
$rel_path = $path;
$rel_path =~ s/^\Q$dir\E\/?//;
$rel_path = "." if $rel_path eq "";
($size, $modified, $perms) = (stat($path))[7, 9, 2];
$perms = sprintf("%o", $perms & 07777);
print "$type|$dir|$path|$size|$modified|$perms\n";
' >>"$TEMP_DATA"
done
# Create output based on format
case "$FORMAT" in
csv)
{
echo "type,directory,path,size,modified,permissions"
# Process the collected data with proper CSV quoting and full directory paths
awk -F'|' '{
# Get the full directory path from column 2
dir_full = $2;
# Get relative path (path - dir prefix)
rel_path = $3;
gsub("^"$2"/", "", rel_path);
if (rel_path == $2) rel_path = ".";
# Properly quote fields that might contain commas
printf "%s,\"%s\",\"%s\",%s,%s,%s\n",
$1, dir_full, rel_path, $4, $5, $6;
}' "$TEMP_DATA"
} >"$OUTPUT"
;;
json)
{
echo "{"
echo " \"timestamp\": \"$TIMESTAMP_HUMAN\","
echo " \"epoch\": $EPOCH,"
echo " \"directories\": ["
# First output the list of directories
first_dir=true
for DIR in "${DIRECTORIES[@]}"; do
if $first_dir; then
first_dir=false
else
echo ","
fi
echo " {"
echo " \"path\": \"$DIR\","
echo " \"name\": \"$(basename "$DIR")\""
echo -n " }"
done
echo ""
echo " ],"
echo " \"entries\": ["
# Process entries for JSON output with proper null handling
awk -F'|' '
BEGIN { first = 1 }
{
if (!first) printf ",\n"
type = $1
dir = $2 # Full directory path
path = $3
size = $4
modified = $5
perms = $6
# Get relative path
rel_path = path
gsub("^"dir"/", "", rel_path)
if (rel_path == dir) rel_path = "."
# Format with null for empty values
printf " {\n \"type\": \"%s\",\n \"directory\": \"%s\",\n \"path\": \"%s\"",
type, dir, rel_path
# Handle potentially null values
if (size == "" || size == 0)
printf ",\n \"size\": null"
else
printf ",\n \"size\": %s", size
if (modified == "")
printf ",\n \"modified\": null"
else
printf ",\n \"modified\": %s", modified
if (perms == "")
printf ",\n \"permissions\": null"
else
printf ",\n \"permissions\": \"%s\"", perms
printf "\n }"
first = 0
}' "$TEMP_DATA"
echo ""
echo " ]"
echo "}"
} >"$OUTPUT"
;;
*)
echo "Error: Unknown format: $FORMAT"
echo "Supported formats: csv, json"
exit 1
;;
esac
# If output is not stdout, print a confirmation message
if [[ "$OUTPUT" != "/dev/stdout" ]]; then
echo "Snapshot created: $OUTPUT"
fi

View File

@ -1,58 +1,137 @@
use crate::errors::{ProjectFinderError, Result}; use crate::{
dependencies::Dependencies,
errors::{ProjectFinderError, Result},
};
use regex::{Regex, escape};
use std::{ use std::{
collections::HashMap,
fmt::Display,
path::{Path, PathBuf}, path::{Path, PathBuf},
process::Stdio, process::Stdio,
}; };
use tokio::process::Command; use tokio::{
fs::read_to_string,
io::{AsyncBufReadExt, BufReader},
process::Command,
};
use tracing::{debug, warn}; use tracing::{debug, warn};
use crate::dependencies::Dependencies; /// Helper to wrap command errors in a uniform way.
fn wrap_command_error<E: Display>(action: &str, err: E) -> ProjectFinderError {
ProjectFinderError::CommandExecutionFailed(format!("{action}: {err}"))
}
/// Run fd command to find files and directories /// Run the `fd` command to find files matching one or more literal patterns.
///
/// The function builds a combined regex pattern from the list of patterns, runs the
/// command asynchronously, and collects matching file paths in a map keyed by the literal
/// file name.
///
/// # Arguments
///
/// - `deps`: Dependencies hold the path to the `fd` binary.
/// - `dir`: The directory in which to search.
/// - `patterns`: A list of file name patterns (literals) to match.
/// - `max_depth`: The maximum directory depth for the search.
///
/// # Returns
///
/// A map where each key is one of the patterns and the value is the list of matching
/// file paths.
pub async fn find_files( pub async fn find_files(
deps: &Dependencies, deps: &Dependencies,
dir: &Path, dir: &Path,
pattern: &str, patterns: &[&str],
max_depth: usize, max_depth: usize,
) -> Result<Vec<PathBuf>> { ) -> Result<HashMap<String, Vec<PathBuf>>> {
let mut cmd = Command::new(&deps.fd_path); // Build a regex pattern that matches any of the provided (literal) patterns.
let combined_patterns = format!(
"({})",
patterns
.iter()
.map(|pattern| escape(pattern))
.collect::<Vec<_>>()
.join("|")
);
let mut cmd = Command::new(&deps.fd_path);
cmd.arg("--hidden") cmd.arg("--hidden")
.arg("--no-ignore-vcs") .arg("--no-ignore-vcs")
.arg("--type") .arg("--type")
.arg("f") .arg("f")
.arg("--max-depth") .arg("--max-depth")
.arg(max_depth.to_string()) .arg(max_depth.to_string())
.arg(pattern) .arg(&combined_patterns)
.arg(dir) .arg(dir)
.stdout(Stdio::piped()); .stdout(Stdio::piped());
debug!("Running: fd {} in {}", pattern, dir.display()); debug!("Running: fd with combined pattern in {}", dir.display());
let output = cmd.output().await.map_err(|e| { let mut child = cmd.spawn().map_err(|e| {
ProjectFinderError::CommandExecutionFailed(format!("Failed to execute fd: {e}")) ProjectFinderError::CommandExecutionFailed(format!("Failed to spawn fd: {e}"))
})?; })?;
if !output.status.success() { // Capture stdout and wrap it with a buffered reader.
let stderr = String::from_utf8_lossy(&output.stderr); let stdout = child.stdout.take().ok_or_else(|| {
warn!("fd command failed: {stderr}"); ProjectFinderError::CommandExecutionFailed("Failed to capture stdout".into())
return Ok(Vec::new()); })?;
let reader = BufReader::new(stdout);
let mut lines = reader.lines();
// Prepare the results map with an empty vector for each pattern.
let mut results = patterns
.iter()
.map(|pattern| ((*pattern).to_string(), Vec::new()))
.collect::<HashMap<_, _>>();
// Stream and process output as lines arrive.
while let Some(line) = lines
.next_line()
.await
.map_err(|e| wrap_command_error("Failed to read stdout", e))?
{
let path = PathBuf::from(line);
// For each found file, only add it if its file name exactly matches one
// of the provided patterns.
if let Some(file_name) = path.file_name().and_then(|f| f.to_str()) {
if let Some(entries) = results.get_mut(file_name) {
entries.push(path);
}
}
} }
let stdout = String::from_utf8(output.stdout).map_err(ProjectFinderError::Utf8Error)?; // Wait for the command to finish.
let status = child
.wait()
.await
.map_err(|e| wrap_command_error("Failed to wait process", e))?;
if !status.success() {
warn!("fd command exited with non-zero status: {status}");
}
let paths = stdout.lines().map(PathBuf::from).collect(); Ok(results)
Ok(paths)
} }
/// Find Git repositories /// Find Git repositories by searching for '.git' directories.
///
/// This function invokes the `fd` command with the pattern '^.git$'. For each
/// found directory, it returns the parent path (the Git repository root).
///
/// # Arguments
///
/// - `deps`: Dependencies containing the path to the `fd` binary.
/// - `dir`: The directory to search for Git repositories.
/// - `max_depth`: The maximum directory depth to search.
///
/// # Returns
///
/// A vector of paths representing the roots of Git repositories.
pub async fn find_git_repos( pub async fn find_git_repos(
deps: &Dependencies, deps: &Dependencies,
dir: &Path, dir: &Path,
max_depth: usize, max_depth: usize,
) -> Result<Vec<PathBuf>> { ) -> Result<Vec<PathBuf>> {
let mut cmd = Command::new(&deps.fd_path); let mut cmd = Command::new(&deps.fd_path);
cmd.arg("--hidden") cmd.arg("--hidden")
.arg("--type") .arg("--type")
.arg("d") .arg("d")
@ -64,21 +143,22 @@ pub async fn find_git_repos(
debug!("Finding git repos in {}", dir.display()); debug!("Finding git repos in {}", dir.display());
let output = cmd.output().await.map_err(|e| { let output = cmd
ProjectFinderError::CommandExecutionFailed(format!("Failed to find git repositories: {e}")) .output()
})?; .await
.map_err(|e| wrap_command_error("Failed to find git repositories", e))?;
if !output.status.success() { if !output.status.success() {
let stderr = String::from_utf8_lossy(&output.stderr); let stderr = String::from_utf8_lossy(&output.stderr);
warn!("fd command failed: {}", stderr); warn!("fd command failed: {stderr}");
return Ok(Vec::new()); return Ok(Vec::new());
} }
let stdout = String::from_utf8(output.stdout).map_err(ProjectFinderError::Utf8Error)?; let stdout = String::from_utf8(output.stdout).map_err(ProjectFinderError::Utf8Error)?;
// For each found '.git' directory, return its parent directory.
let paths = stdout let paths = stdout
.lines() .lines()
// Convert .git directories to their parent (the actual repo root)
.filter_map(|line| { .filter_map(|line| {
let path = PathBuf::from(line); let path = PathBuf::from(line);
path.parent().map(std::path::Path::to_path_buf) path.parent().map(std::path::Path::to_path_buf)
@ -88,18 +168,26 @@ pub async fn find_git_repos(
Ok(paths) Ok(paths)
} }
/// Run grep on a file to check for a pattern /// Read a file into memory and check if it contains any match of the provided regex.
pub async fn grep_file(deps: &Dependencies, file: &Path, pattern: &str) -> Result<bool> { ///
let mut cmd = Command::new(&deps.rg_path); /// # Arguments
///
cmd.arg("-q") // quiet mode, just return exit code /// - `file`: The file to read.
.arg("-e") // explicitly specify pattern /// - `pattern`: The regex pattern to search for.
.arg(pattern) ///
.arg(file); /// # Returns
///
let status = cmd.status().await.map_err(|e| { /// `true` if the regex matches the files contents, `false` otherwise.
ProjectFinderError::CommandExecutionFailed(format!("Failed to execute ripgrep: {e}")) pub async fn grep_file_in_memory(file: &Path, pattern: &str) -> Result<bool> {
let contents = read_to_string(file).await.map_err(|e| {
ProjectFinderError::CommandExecutionFailed(format!(
"Failed to read file {}: {e}",
file.display()
))
})?; })?;
Ok(status.success()) let re = Regex::new(pattern)
.map_err(|e| wrap_command_error(&format!("Invalid regex patter {pattern}"), e))?;
Ok(re.is_match(&contents))
} }

View File

@ -1,4 +1,5 @@
use clap::Parser; use clap::Parser;
use std::path::PathBuf;
#[derive(Debug, Parser, Clone)] #[derive(Debug, Parser, Clone)]
#[clap( #[clap(
@ -9,7 +10,7 @@ use clap::Parser;
pub struct Config { pub struct Config {
/// Directories to search for projects /// Directories to search for projects
#[clap(default_value = ".")] #[clap(default_value = ".")]
pub paths: Vec<String>, pub paths: Vec<PathBuf>,
/// Maximum search depth /// Maximum search depth
#[clap(short, long, default_value = "5")] #[clap(short, long, default_value = "5")]

View File

@ -2,40 +2,50 @@ use crate::errors::{ProjectFinderError, Result};
use tracing::info; use tracing::info;
use which::which; use which::which;
const FD_PATH: [&str; 2] = ["fd", "fdfind"];
/// Represents external dependencies required by the application.
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub struct Dependencies { pub struct Dependencies {
pub fd_path: String, pub fd_path: String,
pub rg_path: String,
} }
impl Dependencies { impl Dependencies {
pub fn new(fd_path: impl Into<String>, rg_path: impl Into<String>) -> Self { /// Creates a new instance of `Dependencies` from the given `fd` binary path.
pub fn new(fd_path: impl Into<String>) -> Self {
Self { Self {
fd_path: fd_path.into(), fd_path: fd_path.into(),
rg_path: rg_path.into(),
} }
} }
/// Checks if all required dependencies are available, returning an instance of
/// `Dependencies` with the paths set appropriately.
///
/// At the moment, this only verifies that the `fd` binary is available.
///
/// # Errors
///
/// Returns a `ProjectFinderError::DependencyNotFound` error if `fd` is not found.
pub fn check() -> Result<Self> { pub fn check() -> Result<Self> {
info!("Checking dependencies..."); info!("Checking dependencies...");
let fd_path = which("fd").map_err(|_| { let fd_path = FD_PATH
.iter()
.find_map(|binary| {
if let Ok(path) = which(binary) {
let fd_path = path.to_string_lossy().into_owned();
info!("Found {binary} at: {}", fd_path);
return Some(fd_path);
}
None
})
.ok_or_else(|| {
ProjectFinderError::DependencyNotFound( ProjectFinderError::DependencyNotFound(
"fd - install from https://github.com/sharkdp/fd".into(), "Neither 'fd' nor 'fdfind' was found. Please install fd from https://github.com/sharkdp/fd"
.into(),
) )
})?; })?;
let rg_path = which("rg").map_err(|_| { Ok(Self::new(fd_path))
ProjectFinderError::DependencyNotFound(
"ripgrep (rg) - install from https://github.com/BurntSushi/ripgrep".into(),
)
})?;
info!("Found fd at: {}", fd_path.display());
info!("Found ripgrep at: {}", rg_path.display());
Ok(Self::new(
fd_path.to_string_lossy(),
rg_path.to_string_lossy(),
))
} }
} }

View File

@ -1,8 +1,9 @@
use crate::{ use crate::{
commands::{find_files, find_git_repos, grep_file}, commands::{find_files, find_git_repos, grep_file_in_memory},
config::Config, config::Config,
dependencies::Dependencies, dependencies::Dependencies,
errors::{ProjectFinderError, Result}, errors::{ProjectFinderError, Result},
marker::MarkerType,
}; };
use futures::future::join_all; use futures::future::join_all;
use std::{ use std::{
@ -10,124 +11,18 @@ use std::{
path::{Path, PathBuf}, path::{Path, PathBuf},
sync::Arc, sync::Arc,
}; };
use tokio::sync::Mutex; use tokio::{
fs::metadata,
spawn,
sync::{RwLock, Semaphore},
};
use tracing::{debug, info}; use tracing::{debug, info};
type ProjectSet = Arc<Mutex<HashSet<PathBuf>>>; type ProjectSet = Arc<RwLock<HashSet<PathBuf>>>;
type WorkspaceCache = Arc<Mutex<HashMap<PathBuf, bool>>>; type WorkspaceCache = Arc<RwLock<HashMap<PathBuf, bool>>>;
type RootCache = Arc<Mutex<HashMap<(PathBuf, String), PathBuf>>>; type RootCache = Arc<RwLock<HashMap<(PathBuf, String), PathBuf>>>;
#[derive(Debug, Clone, PartialEq, Eq)] const MARKER_PATTERNS: [&str; 13] = [
pub enum MarkerType {
PackageJson,
CargoToml,
DenoJson,
BuildFile(String),
OtherConfig(String),
}
#[derive(Debug, Clone)]
pub struct ProjectFinder {
config: Config,
deps: Dependencies,
discovered_projects: ProjectSet,
workspace_cache: WorkspaceCache,
root_cache: RootCache,
}
impl ProjectFinder {
pub fn new(config: Config, deps: Dependencies) -> Self {
Self {
config,
deps,
discovered_projects: Arc::new(Mutex::new(HashSet::new())),
workspace_cache: Arc::new(Mutex::new(HashMap::new())),
root_cache: Arc::new(Mutex::new(HashMap::new())),
}
}
pub async fn find_projects(&self) -> Result<Vec<PathBuf>> {
let semaphore = Arc::new(tokio::sync::Semaphore::new(8)); // Limit to 8 concurrent tasks
let mut handles = vec![];
for path in &self.config.paths {
let path_buf = PathBuf::from(path);
if !path_buf.is_dir() {
return Err(ProjectFinderError::PathNotFound(path_buf));
}
if self.config.verbose {
info!("Searching in: {}", path);
}
let finder_clone = self.clone();
let path_clone = path_buf.clone();
let semaphore_clone = Arc::clone(&semaphore);
// Spawn a task for each directory with semaphore permit
let handle = tokio::spawn(async move {
let _permit = semaphore_clone.acquire().await.map_err(|e| {
ProjectFinderError::CommandExecutionFailed(format!(
"Failed to aquire semaphore: {e}"
))
})?;
finder_clone.process_directory(&path_clone).await
});
handles.push(handle);
}
let handle_results = join_all(handles).await;
let mut errors = handle_results
.into_iter()
.filter_map(|handle_result| match handle_result {
Ok(task_result) => task_result.err().map(|e| {
debug!("Task failed: {}", e);
e
}),
Err(e) => {
debug!("Task join error: {}", e);
Some(ProjectFinderError::CommandExecutionFailed(format!(
"Task panicked: {e}",
)))
}
})
.collect::<Vec<_>>();
// Return first error if any occurred
if !errors.is_empty() && errors.len() == self.config.paths.len() {
// Only fail if all tasks failed
return Err(errors.remove(0));
}
// Return sorted results
let mut projects: Vec<PathBuf> = {
let projects_guard = self.discovered_projects.lock().await;
projects_guard.iter().cloned().collect()
};
projects.sort();
// Apply max_results if set
if self.config.max_results > 0 && projects.len() > self.config.max_results {
projects.truncate(self.config.max_results);
}
Ok(projects)
}
async fn process_directory(&self, dir: &Path) -> Result<()> {
// First find all git repositories (usually the most reliable project indicators)
let git_repos = find_git_repos(&self.deps, dir, self.config.depth).await?;
{
let mut projects = self.discovered_projects.lock().await;
projects.extend(git_repos);
}
// Find relevant marker files
let marker_patterns = [
"package.json", "package.json",
"pnpm-workspace.yaml", "pnpm-workspace.yaml",
"lerna.json", "lerna.json",
@ -141,14 +36,119 @@ impl ProjectFinder {
"deno.json", "deno.json",
"deno.jsonc", "deno.jsonc",
"bunfig.toml", "bunfig.toml",
]; ];
for pattern in &marker_patterns { /// Check whether a given path exists.
let paths = find_files(&self.deps, dir, pattern, self.config.depth).await?; async fn path_exists(path: &Path) -> bool {
metadata(path).await.is_ok()
}
/// Struct responsible for scanning directories and detecting projects.
#[derive(Debug, Clone)]
pub struct ProjectFinder {
config: Config,
deps: Dependencies,
discovered_projects: ProjectSet,
workspace_cache: WorkspaceCache,
root_cache: RootCache,
}
impl ProjectFinder {
/// Create a new `ProjectFinder` instance.
pub fn new(config: Config, deps: Dependencies) -> Self {
Self {
config,
deps,
discovered_projects: Arc::new(RwLock::new(HashSet::new())),
workspace_cache: Arc::new(RwLock::new(HashMap::new())),
root_cache: Arc::new(RwLock::new(HashMap::new())),
}
}
/// Find projects in the configured paths.
pub async fn find_projects(&self) -> Result<Vec<PathBuf>> {
let semaphore = Arc::new(Semaphore::new(8)); // Limit to 8 concurrent tasks
let mut handles = Vec::new();
for path in &self.config.paths {
if !path.is_dir() {
return Err(ProjectFinderError::PathNotFound(path.clone()));
}
if self.config.verbose {
info!("Searching in: {}", path.display());
}
let finder_clone = self.clone();
let path_clone = path.clone();
let semaphore_clone = Arc::clone(&semaphore);
let handle = spawn(async move {
let _permit = semaphore_clone.acquire().await.map_err(|e| {
ProjectFinderError::CommandExecutionFailed(format!(
"Failed to aquire semaphore: {e}"
))
})?;
finder_clone.process_directory(&path_clone).await
});
handles.push(handle);
}
// Await all tasks and collect errors.
let handle_results = join_all(handles).await;
let mut errors = handle_results
.into_iter()
.filter_map(|handle_result| match handle_result {
Ok(task_result) => task_result.err().map(|e| {
debug!("Task failed: {e}");
e
}),
Err(e) => {
debug!("Task join error: {e}");
Some(ProjectFinderError::CommandExecutionFailed(format!(
"Task panicked: {e}",
)))
}
})
.collect::<Vec<_>>();
// If all tasks failed, return one of the errors.
if !errors.is_empty() && errors.len() == self.config.paths.len() {
return Err(errors.remove(0));
}
// Gather discovered projects, sort and apply max_results limit, if set.
let mut projects = self
.discovered_projects
.read()
.await
.iter()
.cloned()
.collect::<Vec<PathBuf>>();
projects.sort();
if self.config.max_results > 0 && projects.len() > self.config.max_results {
projects.truncate(self.config.max_results);
}
Ok(projects)
}
/// Process a single directory by scanning for git repositories and marker files.
async fn process_directory(&self, dir: &Path) -> Result<()> {
// Look for git repositories first.
let git_repos = find_git_repos(&self.deps, dir, self.config.depth).await?;
{
let mut projects = self.discovered_projects.write().await;
projects.extend(git_repos);
}
// Look for marker files.
let marker_map = find_files(&self.deps, dir, &MARKER_PATTERNS, self.config.depth).await?;
for (pattern, paths) in marker_map {
for path in paths { for path in paths {
if let Some(parent_dir) = path.parent() { if let Some(parent_dir) = path.parent() {
self.process_marker(parent_dir, pattern).await?; self.process_marker(parent_dir, &pattern).await?;
} }
} }
} }
@ -156,17 +156,10 @@ impl ProjectFinder {
Ok(()) Ok(())
} }
/// Process a marker file found in a directory.
async fn process_marker(&self, dir: &Path, marker_name: &str) -> Result<()> { async fn process_marker(&self, dir: &Path, marker_name: &str) -> Result<()> {
// Determine marker type // Determine marker type
let marker_type = match marker_name { let marker_type = marker_name.parse().expect("How did we get here?");
"package.json" => MarkerType::PackageJson,
"Cargo.toml" => MarkerType::CargoToml,
"deno.json" | "deno.jsonc" => MarkerType::DenoJson,
"Makefile" | "CMakeLists.txt" | "justfile" | "Justfile" => {
MarkerType::BuildFile(marker_name.to_string())
}
_ => MarkerType::OtherConfig(marker_name.to_string()),
};
// Find project root // Find project root
let project_root = self.find_project_root(dir, &marker_type).await?; let project_root = self.find_project_root(dir, &marker_type).await?;
@ -176,7 +169,7 @@ impl ProjectFinder {
// valid nested projects of different types) // valid nested projects of different types)
let mut should_add = true; let mut should_add = true;
{ {
let projects = self.discovered_projects.lock().await; let projects = self.discovered_projects.read().await;
for known_project in projects.iter() { for known_project in projects.iter() {
// Check if this is a direct parent (not just any ancestor) // Check if this is a direct parent (not just any ancestor)
let is_direct_parent = project_root let is_direct_parent = project_root
@ -195,8 +188,7 @@ impl ProjectFinder {
} }
if should_add { if should_add {
let mut projects = self.discovered_projects.lock().await; self.discovered_projects.write().await.insert(project_root);
projects.insert(project_root);
} }
Ok(()) Ok(())
@ -206,7 +198,7 @@ impl ProjectFinder {
// Check cache // Check cache
let cache_key = (dir.to_path_buf(), format!("{marker_type:?}")); let cache_key = (dir.to_path_buf(), format!("{marker_type:?}"));
{ {
let cache = self.root_cache.lock().await; let cache = self.root_cache.read().await;
if let Some(root) = cache.get(&cache_key) { if let Some(root) = cache.get(&cache_key) {
return Ok(root.clone()); return Ok(root.clone());
} }
@ -246,8 +238,8 @@ impl ProjectFinder {
} }
let cargo_toml = parent.join("Cargo.toml"); let cargo_toml = parent.join("Cargo.toml");
if cargo_toml.exists() if path_exists(&cargo_toml).await
&& grep_file(&self.deps, &cargo_toml, r"^\[workspace\]").await? && grep_file_in_memory(&cargo_toml, r"^\[workspace\]").await?
{ {
result = parent.to_path_buf(); result = parent.to_path_buf();
break; break;
@ -309,7 +301,7 @@ impl ProjectFinder {
// Cache the result // Cache the result
self.root_cache self.root_cache
.lock() .write()
.await .await
.insert(cache_key, result.clone()); .insert(cache_key, result.clone());
@ -319,7 +311,7 @@ impl ProjectFinder {
async fn is_workspace_root(&self, dir: &Path) -> Result<bool> { async fn is_workspace_root(&self, dir: &Path) -> Result<bool> {
// Check cache // Check cache
{ {
let cache = self.workspace_cache.lock().await; let cache = self.workspace_cache.read().await;
if let Some(&result) = cache.get(dir) { if let Some(&result) = cache.get(dir) {
return Ok(result); return Ok(result);
} }
@ -348,9 +340,9 @@ impl ProjectFinder {
// Check for workspace by pattern matching // Check for workspace by pattern matching
for (file, pattern) in &workspace_patterns { for (file, pattern) in &workspace_patterns {
if file.exists() && grep_file(&self.deps, file, pattern).await? { if path_exists(file).await && grep_file_in_memory(file, pattern).await? {
self.workspace_cache self.workspace_cache
.lock() .write()
.await .await
.insert(dir.to_path_buf(), true); .insert(dir.to_path_buf(), true);
return Ok(true); return Ok(true);
@ -359,9 +351,9 @@ impl ProjectFinder {
// Check for workspace by file existence // Check for workspace by file existence
for file in &workspace_files { for file in &workspace_files {
if file.exists() { if path_exists(file).await {
self.workspace_cache self.workspace_cache
.lock() .write()
.await .await
.insert(dir.to_path_buf(), true); .insert(dir.to_path_buf(), true);
return Ok(true); return Ok(true);
@ -370,7 +362,7 @@ impl ProjectFinder {
// No workspace found // No workspace found
self.workspace_cache self.workspace_cache
.lock() .write()
.await .await
.insert(dir.to_path_buf(), false); .insert(dir.to_path_buf(), false);
Ok(false) Ok(false)

View File

@ -3,17 +3,24 @@ mod config;
mod dependencies; mod dependencies;
mod errors; mod errors;
mod finder; mod finder;
mod marker;
use crate::{config::Config, dependencies::Dependencies, finder::ProjectFinder};
use anyhow::{Result, anyhow};
use clap::Parser; use clap::Parser;
use config::Config;
use dependencies::Dependencies;
use finder::ProjectFinder;
use std::process::exit; use std::process::exit;
use tracing::{Level, error}; use tracing::Level;
use tracing_subscriber::FmtSubscriber; use tracing_subscriber::FmtSubscriber;
#[tokio::main] #[tokio::main]
async fn main() { async fn main() {
if let Err(e) = run().await {
eprintln!("{e}");
exit(1);
}
}
async fn run() -> Result<()> {
// Parse CLI arguments // Parse CLI arguments
let config = Config::parse(); let config = Config::parse();
@ -25,42 +32,23 @@ async fn main() {
}; };
let subscriber = FmtSubscriber::builder().with_max_level(log_level).finish(); let subscriber = FmtSubscriber::builder().with_max_level(log_level).finish();
if let Err(e) = tracing::subscriber::set_global_default(subscriber) { tracing::subscriber::set_global_default(subscriber)
eprintln!("Failed to set up logging: {e}"); .map_err(|e| anyhow!("Failed to set up logging: {e}"))?;
exit(1);
}
// Check for required dependencies // Check for required dependencies
let deps = match Dependencies::check() { let deps = Dependencies::check().map_err(|e| anyhow!("{e}"))?;
Ok(deps) => deps,
Err(e) => {
error!("{e}");
eprintln!("Error: {e}");
eprintln!(
"This tool requires both 'fd' and 'ripgrep' (rg) to be installed and available in your PATH."
);
eprintln!("Please install the missing dependencies and try again.");
eprintln!("\nInstallation instructions:");
eprintln!(" fd: https://github.com/sharkdp/fd#installation");
eprintln!(" ripgrep: https://github.com/BurntSushi/ripgrep#installation");
exit(1);
}
};
// Create finder and search for projects // Create finder and search for projects
let finder = ProjectFinder::new(config, deps); let finder = ProjectFinder::new(config, deps);
match finder.find_projects().await { let projects = finder
Ok(projects) => { .find_projects()
// Output results .await
.map_err(|e| anyhow!("Failed to find projects: {e}"))?;
for project in projects { for project in projects {
println!("{}", project.display()); println!("{}", project.display());
} }
}
Err(e) => { Ok(())
error!("Failed to find projects: {e}");
eprintln!("Error: {e}");
exit(1);
}
}
} }

26
src/marker.rs Normal file
View File

@ -0,0 +1,26 @@
use std::{convert::Infallible, str::FromStr};
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum MarkerType {
PackageJson,
CargoToml,
DenoJson,
BuildFile(String),
OtherConfig(String),
}
impl FromStr for MarkerType {
type Err = Infallible;
fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
Ok(match s {
"package.json" => Self::PackageJson,
"Cargo.toml" => Self::CargoToml,
"deno.json" | "deno.jsonc" => Self::DenoJson,
"Makefile" | "CMakeLists.txt" | "justfile" | "Justfile" => {
Self::BuildFile(s.to_string())
}
_ => Self::OtherConfig(s.to_string()),
})
}
}