Skip to content

refactor(core): decouple progress reporting from indicatif#5

Merged
StudentWeis merged 1 commit into
mainfrom
refactor/4-decouple-progress-from-core
Apr 25, 2026
Merged

refactor(core): decouple progress reporting from indicatif#5
StudentWeis merged 1 commit into
mainfrom
refactor/4-decouple-progress-from-core

Conversation

@StudentWeis
Copy link
Copy Markdown
Owner

Summary

Decouple the core layer from indicatif by introducing a first-class
ProgressReporter trait with a zero-cost NoopProgress default. Terminal
rendering 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

  • New src/core/progress.rs: ProgressReporter: Sync trait (default
    set_message / set_total / inc bodies) plus NoopProgress. 4 unit
    tests cover the no-op path, trait-object usage, custom reporters, and the
    Sync contract.
  • Breaking API (pre-1.0, intentional):
    • Remove find_references_with_progress, mv_with_progress,
      rename_with_progress, preview_move_with_progress.
    • Merge the progress parameter into find_references, mv,
      preview_move, and rename as a mandatory
      progress: &dyn ProgressReporter. Callers that don't care pass
      &NoopProgress.
  • src/lib.rs: drop the removed *_with_progress re-exports, add
    NoopProgress and ProgressReporter.
  • src/core/{find,mv,rename}.rs: remove use 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 through set_message.
  • src/commands/progress.rs: replace create_spinner/finish with a
    Spinner newtype that implements ProgressReporter, bridging indicatif
    to the core trait while satisfying Rust's orphan rule.
  • src/commands/{find,mv,rename}.rs: call sites switch to Spinner::new +
    spinner.as_reporter().
  • tests/ and benches/ call sites updated to pass &NoopProgress.

Testing

  • scripts/precheck.sh passes locally (cargo check / cargo clippy
    / cargo test / cargo test --benches --no-run).
  • New unit tests cover ProgressReporter + NoopProgress; existing
    272 tests (+1 ignored) still pass.
  • Refactor is purely mechanical — no behavior change beyond the API
    shape; the semantic events emitted to indicatif are unchanged.

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
@StudentWeis StudentWeis merged commit 2ae5c5b into main Apr 25, 2026
8 checks passed
@StudentWeis StudentWeis deleted the refactor/4-decouple-progress-from-core branch April 25, 2026 10:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

refactor(core): decouple progress reporting from indicatif

1 participant