refactor(core): decouple progress reporting from indicatif#5
Merged
Conversation
Introduce a `ProgressReporter` trait in `core::progress` with a `NoopProgress` zero-cost default implementation. The `core` layer now only talks to `&dyn ProgressReporter` and no longer depends on `indicatif` in any of its public signatures — keeping terminal-rendering concerns out of the reusable library surface. Breaking API changes (pre-1.0, acceptable): - Remove `find_references_with_progress`, `mv_with_progress`, `rename_with_progress`, and `preview_move_with_progress`. - Merge the progress parameter directly into `find_references`, `mv`, `preview_move`, and `rename`; callers that don't care pass `&NoopProgress`. - `src/lib.rs` re-exports now include `ProgressReporter` and `NoopProgress`, and drop the removed `*_with_progress` variants. CLI adapter: - `src/commands/progress.rs` replaces `create_spinner`/`finish` with a `Spinner` newtype that implements `ProgressReporter`, bridging indicatif to the core trait without violating the orphan rule. Refs #4
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Decouple the
corelayer fromindicatifby introducing a first-classProgressReportertrait with a zero-costNoopProgressdefault. Terminalrendering is now a CLI-only concern, and the library surface is usable from
non-CLI consumers (GUI, LSP, MCP server, Web service) without dragging a
terminal UI crate along.
Linked Issue
Closes #4
Changes
src/core/progress.rs:ProgressReporter: Synctrait (defaultset_message/set_total/incbodies) plusNoopProgress. 4 unittests cover the no-op path, trait-object usage, custom reporters, and the
Synccontract.find_references_with_progress,mv_with_progress,rename_with_progress,preview_move_with_progress.find_references,mv,preview_move, andrenameas a mandatoryprogress: &dyn ProgressReporter. Callers that don't care pass&NoopProgress.src/lib.rs: drop the removed*_with_progressre-exports, addNoopProgressandProgressReporter.src/core/{find,mv,rename}.rs: removeuse indicatif::ProgressBar;internal helpers (
plan_directory_replacements,preview_regular_file_move,preview_case_only_file_move,preview_directory_move,mv_regular_file,mv_case_only_file,mv_directory) take&dyn ProgressReporter. UI wording(
"Scanning references...") now flows throughset_message.src/commands/progress.rs: replacecreate_spinner/finishwith aSpinnernewtype that implementsProgressReporter, bridging indicatifto the core trait while satisfying Rust's orphan rule.
src/commands/{find,mv,rename}.rs: call sites switch toSpinner::new+spinner.as_reporter().tests/andbenches/call sites updated to pass&NoopProgress.Testing
scripts/precheck.shpasses locally (cargo check/cargo clippy/
cargo test/cargo test --benches --no-run).ProgressReporter+NoopProgress; existing272 tests (+1 ignored) still pass.
shape; the semantic events emitted to
indicatifare unchanged.