Add prune command for removing cached JDKs#46
Conversation
The clear-cache command clears everything. But I often find myself wanting to remove "stale" versions of JDKs without starting from scratch. This commit adds two new commands for doing so: * cjdk rm - to target specifically named cached JDKs * cjdk prune - to remove older JDKs when newer ones are also cached Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
|
I was thinking of a |
|
Well... I sort of am using cjdk like a package manager now, in the sense that whenever possible, I try to install and use OpenJDKs managed by cjdk. I have built several shell commands around it, as shown here:
So I It all works great, but over time, I end up with "too many versions" installed, and I want to remove some redundant ones, but what is "redundant" is a judgment call—it doesn't always align with the But if this sort of usage isn't aligned with your vision for cjdk, I can just write another tool like |
|
Got it. Maybe it can be a flag to Name it Alternatively, we could teach |
|
I pushed another commit implementing your suggestion: now there is only I discussed with Claude whether it might be worth generalizing the We opted not to do so for now. Here is Claude's opinion on why not:
|
Rather than a standalone rm command with package-manager semantics, express "remove specific cached JDKs" as an advanced prune: --keep-none removes every matching JDK instead of keeping the newest of each, and combines with -j for precision. This keeps the cache semantics honest and shrinks the command/API surface. - Drop the rm command and the public remove_jdks(); fold both into prune / prune_jdks(keep_none=True). - Error when --keep-none is combined with --across-(vendors|majors) (grouping is meaningless when keeping none). - Update docs, changelog, and tests accordingly. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The clear-cache command clears everything. But I often find myself wanting to remove "stale" versions of JDKs without starting from scratch. This commit adds two new commands for doing so:
cjdk rm- to target specifically named cached JDKscjdk prune- to remove older JDKs when newer ones are also cachedBecause both commands delete local files, both are gated behind confirmation prompts unless
-y/--yesis given, and the existingcjdk clear-cacheis also now gated as such to avoid someone naively deleting all their cached JDKs (which happened to me this morning 😅).I vibe-coded it with Claude, and also pushed it all as one commit. Apologies if that makes review more burdensome—although I have read through the entire patch and it looks clean and pretty minimal to me. The change of
def clear_cache(ctx: click.Context) -> Noneaddingdry_run: bool, yes: boolparameters without default values is, however, a breaking change.