Conversation
dsmiley
left a comment
There was a problem hiding this comment.
Thanks for remembering to carry this forward!
|
|
||
| /** Console-facing output for package manager operations */ | ||
| @FunctionalInterface | ||
| public interface UserIO { |
There was a problem hiding this comment.
ToolRuntime (in CLI) implements this, i see. What implements this within solr core?
There was a problem hiding this comment.
Disclaimer - Reply via Cursor
Packagemanager uses UserIO directly; it doesn’t implement console output.
PackageManager / RepositoryManager take a UserIO and call print / printSuccess / printError. PackageUtils uses the color constants on the interface. That is how we dropped the CLI dependency.
Implementations:
CLI: ToolRuntime (passed in from PackageTool)
tests: UserIO.NONE
There is no production core path that constructs PackageManager outside the CLI, so core doesn’t need its own console impl.
There was a problem hiding this comment.
That's weird! If UserIO is only implemented in the CLI package yet it's defined outside of that package... it's weird; no? Why are those parts of PackageManager that use UserIO located in PackageManager when they could be in some CLI side place?
There was a problem hiding this comment.
That’s a fair point - it does look inverted.
PackageManager still owns the operation flow today, so the print calls sit next to that logic.
UserIO is only a sink so those calls don’t import org.apache.solr.cli: CLI passes ToolRuntime, and tests use NONE.
I’d be happy to move the user-facing output into PackageTool and leave PackageManager as throw/return. That’s a larger split than this PR was aiming for; I was treating this change as just cutting the CLI dependency.
Can I take that up in a follow-up PR, if that's okay to you.
There was a problem hiding this comment.
I think you could just move the packagemanager package to org.apache.solr.cli.packagemanager and then you wouldn't need the UserIO idea. That's a simpler change.
There was a problem hiding this comment.
Thanks for the suggestion - this is much cleaner.
I’ve moved packagemanager to org.apache.solr.cli.packagemanager and dropped UserIO, so it can use ToolRuntime again. That should also make the later CLI module extraction simpler.
Appreciate you taking the time to steer this. ✨
Description
Context: #4663 (comment)
This is a pre-requisite change needed before we attempt: CLI module movement outside core.
Solution
Used Cursor help in formulating the approach, code is reviewed & vetted by me.
Tests
Please describe the tests you've developed or run to confirm this patch implements the feature or solves the problem.
Checklist
Please review the following and check all that apply:
mainbranch../gradlew check.