Compare commits
2 Commits
16c654a7e6
...
1e7c82e487
Author | SHA1 | Date | |
---|---|---|---|
|
1e7c82e487 | ||
6773122076 |
@ -6,6 +6,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
|
## [0.2.1] - 2024-09-15
|
||||||
|
|
||||||
|
### Added
|
||||||
|
- implement naive fuzzy matcher
|
||||||
|
|
||||||
|
### Other
|
||||||
|
- update dependencies
|
||||||
|
- *(deps)* update rust crate anyhow to v1.0.89
|
||||||
|
|
||||||
## [0.2.0] - 2024-09-14
|
## [0.2.0] - 2024-09-14
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
17
Cargo.lock
generated
17
Cargo.lock
generated
@ -492,6 +492,7 @@ dependencies = [
|
|||||||
"dirs",
|
"dirs",
|
||||||
"dotenv",
|
"dotenv",
|
||||||
"gitea-rs",
|
"gitea-rs",
|
||||||
|
"nucleo-matcher",
|
||||||
"octocrab",
|
"octocrab",
|
||||||
"pretty_assertions",
|
"pretty_assertions",
|
||||||
"prost",
|
"prost",
|
||||||
@ -905,6 +906,16 @@ dependencies = [
|
|||||||
"winapi",
|
"winapi",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "nucleo-matcher"
|
||||||
|
version = "0.3.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "bf33f538733d1a5a3494b836ba913207f14d9d4a1d3cd67030c5061bdd2cac85"
|
||||||
|
dependencies = [
|
||||||
|
"memchr",
|
||||||
|
"unicode-segmentation",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "num-bigint"
|
name = "num-bigint"
|
||||||
version = "0.4.6"
|
version = "0.4.6"
|
||||||
@ -1965,6 +1976,12 @@ dependencies = [
|
|||||||
"tinyvec",
|
"tinyvec",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "unicode-segmentation"
|
||||||
|
version = "1.12.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f6ccf251212114b54433ec949fd6a7841275f9ada20dddd2f29e9ceea4501493"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "untrusted"
|
name = "untrusted"
|
||||||
version = "0.9.0"
|
version = "0.9.0"
|
||||||
|
@ -3,7 +3,7 @@ members = ["crates/*"]
|
|||||||
resolver = "2"
|
resolver = "2"
|
||||||
|
|
||||||
[workspace.package]
|
[workspace.package]
|
||||||
version = "0.2.0"
|
version = "0.2.1"
|
||||||
|
|
||||||
[workspace.dependencies]
|
[workspace.dependencies]
|
||||||
gitnow = { path = "crates/gitnow" }
|
gitnow = { path = "crates/gitnow" }
|
||||||
|
@ -24,6 +24,7 @@ dirs = "5.0.1"
|
|||||||
prost = "0.13.2"
|
prost = "0.13.2"
|
||||||
prost-types = "0.13.2"
|
prost-types = "0.13.2"
|
||||||
bytes = "1.7.1"
|
bytes = "1.7.1"
|
||||||
|
nucleo-matcher = "0.3.1"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
pretty_assertions = "1.4.0"
|
pretty_assertions = "1.4.0"
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
use nucleo_matcher::{pattern::Pattern, Matcher, Utf32Str};
|
||||||
|
|
||||||
use crate::{app::App, cache::CacheApp, projects_list::ProjectsListApp};
|
use crate::{app::App, cache::CacheApp, projects_list::ProjectsListApp};
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
@ -10,8 +12,7 @@ impl RootCommand {
|
|||||||
Self { app }
|
Self { app }
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tracing::instrument(skip(self))]
|
pub async fn execute(&mut self, search: Option<impl Into<String>>) -> anyhow::Result<()> {
|
||||||
pub async fn execute(&mut self) -> anyhow::Result<()> {
|
|
||||||
tracing::debug!("executing");
|
tracing::debug!("executing");
|
||||||
|
|
||||||
let repositories = match self.app.cache().get().await? {
|
let repositories = match self.app.cache().get().await? {
|
||||||
@ -26,8 +27,28 @@ impl RootCommand {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
for repo in &repositories {
|
let haystack = repositories
|
||||||
//tracing::info!("repo: {}", repo.to_rel_path().display());
|
.iter()
|
||||||
|
.map(|r| r.to_rel_path().display().to_string());
|
||||||
|
|
||||||
|
let needle = match search {
|
||||||
|
Some(needle) => needle.into(),
|
||||||
|
None => todo!(),
|
||||||
|
};
|
||||||
|
|
||||||
|
let pattern = Pattern::new(
|
||||||
|
&needle,
|
||||||
|
nucleo_matcher::pattern::CaseMatching::Ignore,
|
||||||
|
nucleo_matcher::pattern::Normalization::Smart,
|
||||||
|
nucleo_matcher::pattern::AtomKind::Fuzzy,
|
||||||
|
);
|
||||||
|
let mut matcher = Matcher::new(nucleo_matcher::Config::DEFAULT);
|
||||||
|
let res = pattern.match_list(haystack, &mut matcher);
|
||||||
|
|
||||||
|
let res = res.iter().take(10).rev().collect::<Vec<_>>();
|
||||||
|
|
||||||
|
for (repo, _score) in res {
|
||||||
|
tracing::debug!("repo: {:?}", repo);
|
||||||
}
|
}
|
||||||
|
|
||||||
tracing::info!("amount of repos fetched {}", repositories.len());
|
tracing::info!("amount of repos fetched {}", repositories.len());
|
||||||
|
@ -20,6 +20,9 @@ mod projects_list;
|
|||||||
struct Command {
|
struct Command {
|
||||||
#[command(subcommand)]
|
#[command(subcommand)]
|
||||||
command: Option<Commands>,
|
command: Option<Commands>,
|
||||||
|
|
||||||
|
#[arg()]
|
||||||
|
search: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Subcommand)]
|
#[derive(Subcommand)]
|
||||||
@ -51,7 +54,7 @@ async fn main() -> anyhow::Result<()> {
|
|||||||
match cli.command {
|
match cli.command {
|
||||||
Some(_) => todo!(),
|
Some(_) => todo!(),
|
||||||
None => {
|
None => {
|
||||||
RootCommand::new(app).execute().await?;
|
RootCommand::new(app).execute(cli.search.as_ref()).await?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user