Skip to content

Commit 14006b8

Browse files
committed
chore: cleanup API
1 parent ab28026 commit 14006b8

8 files changed

Lines changed: 39 additions & 38 deletions

File tree

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@ resolver = "3"
44

55
[workspace.package]
66
edition = "2024"
7-
rust-version = "1.93"
8-
license = "MIT, APACHE-2.0"
7+
rust-version = "1.94"
8+
license = "MIT OR Apache-2.0"
9+
authors = ["Akrm Al-Hakimi <alhakimiakrmj@gmail.com>"]
910
repository = "https://github.com/cachebag/unrot"
11+
homepage = "https://github.com/cachebag/unrot"
1012

1113
[profile.bench]
1214
debug = true

cli/Cargo.toml

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,21 @@
11
[package]
2-
name = "unrot_cli"
2+
name = "unrot"
33
version = "0.1.0"
4-
edition = "2024"
4+
description = "Find and interactively repair broken symlinks with fuzzy matching"
5+
edition.workspace = true
6+
rust-version.workspace = true
7+
license.workspace = true
8+
authors.workspace = true
9+
repository.workspace = true
10+
homepage.workspace = true
11+
documentation = "https://github.com/cachebag/unrot"
12+
keywords = ["symlink", "broken-symlink", "fuzzy-matching", "filesystem", "cli"]
13+
categories = ["command-line-utilities", "filesystem"]
514

615
[[bin]]
716
name = "unrot"
817
path = "src/main.rs"
918

1019
[dependencies]
1120
clap = { version = "4.6.0", features = ["derive"] }
12-
unrot_core = { path = "../core" }
21+
unrot_core = { version = "0.1.0", path = "../core" }

core/Cargo.toml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
11
[package]
22
name = "unrot_core"
33
version = "0.1.0"
4-
edition = "2024"
4+
description = "Core library for unrot — find and repair broken symlinks with fuzzy matching"
5+
edition.workspace = true
6+
rust-version.workspace = true
7+
license.workspace = true
8+
authors.workspace = true
9+
repository.workspace = true
10+
homepage.workspace = true
11+
documentation = "https://docs.rs/unrot_core"
12+
keywords = ["symlink", "broken-symlink", "fuzzy-matching", "filesystem"]
13+
categories = ["command-line-utilities", "filesystem"]
514

615
[dependencies]
716
walkdir = "2.5.0"

core/src/fuzzy.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use crate::scanner::BrokenSymlink;
88
//
99
// We could easily use a library for this, but it's trivial
1010
// enough in our case to where it's not worth the dependency here.
11-
pub fn levenshtein(a: &str, b: &str) -> usize {
11+
pub(crate) fn levenshtein(a: &str, b: &str) -> usize {
1212
let a: Vec<char> = a.chars().collect();
1313
let b: Vec<char> = b.chars().collect();
1414
let (m, n) = (a.len(), b.len());
@@ -46,7 +46,7 @@ fn dir_components(path: &Path) -> Vec<String> {
4646
.collect()
4747
}
4848

49-
pub fn score_candidate(broken: &BrokenSymlink, candidate: &Path, search_root: &Path) -> f64 {
49+
fn score_candidate(broken: &BrokenSymlink, candidate: &Path, search_root: &Path) -> f64 {
5050
let target_name = broken
5151
.target
5252
.file_name()

core/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ pub mod fuzzy;
22
pub mod resolver;
33
pub mod scanner;
44

5-
pub use fuzzy::{DEFAULT_IGNORE, ScoredCandidate, find_candidates};
6-
pub use resolver::{Action, RepairCase, Resolution, Summary, TerminalIO, run};
5+
pub use fuzzy::{find_candidates, ScoredCandidate, DEFAULT_IGNORE};
6+
pub use resolver::{run, Action, RepairCase, ResolverIO, Summary, TerminalIO};
77
pub use scanner::{BrokenSymlink, find_broken_symlinks};

core/src/resolver/mod.rs

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
1-
pub mod action;
2-
pub mod confirm;
3-
pub mod display;
4-
pub mod fs_ops;
5-
pub mod input;
1+
pub(crate) mod action;
2+
pub(crate) mod confirm;
3+
pub(crate) mod display;
4+
pub(crate) mod fs_ops;
5+
pub(crate) mod input;
66
pub mod io;
77
pub mod model;
8-
pub mod session;
8+
pub(crate) mod session;
99

10-
pub use action::{Resolved, resolve, resolve_custom};
11-
pub use confirm::{format_confirmation, needs_confirmation, parse_confirmation};
12-
pub use display::{format_actions, format_candidates, format_header, present};
13-
pub use fs_ops::{FsError, execute};
14-
pub use input::{ParseError, ParsedInput, parse_choice};
10+
pub use display::present;
1511
pub use io::{ResolverIO, TerminalIO};
16-
pub use model::{Action, RepairCase, Resolution, Summary};
12+
pub use model::{Action, RepairCase, Summary};
1713
pub use session::run;

core/src/resolver/model.rs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,6 @@ pub enum Action {
5353
Skip,
5454
}
5555

56-
pub struct Resolution {
57-
pub link: PathBuf,
58-
pub action: Action,
59-
}
60-
6156
#[derive(Debug, Default)]
6257
pub struct Summary {
6358
pub relinked: usize,
@@ -125,16 +120,6 @@ mod tests {
125120
assert!(case.has_candidates());
126121
}
127122

128-
#[test]
129-
fn resolution_pairs_link_with_action() {
130-
let Resolution { link, action } = Resolution {
131-
link: "/some/link".into(),
132-
action: Action::Remove,
133-
};
134-
assert_eq!(link, PathBuf::from("/some/link"));
135-
assert_eq!(action, Action::Remove);
136-
}
137-
138123
#[test]
139124
fn action_equality() {
140125
assert_eq!(Action::Relink("/a".into()), Action::Relink("/a".into()));

0 commit comments

Comments
 (0)