Repository navigation
feat: align native subcommands on shared output styling - #461
Conversation
There was a problem hiding this comment.
Reviewed the full diff and ran a focused pass over the ui/helpers modules, the shared cli/help layer, and the five migrated binaries against master. CI is green on all three platforms (fmt / clippy -D warnings / test all pass). LGTM. 👍
No bugs found. The load-bearing invariants hold:
- stdout/stderr contract preserved — all captured data (
homepath,versionstring,currentoutput) stays on stdout; only conversational text moved to stderr.$(sdk home java 21)and friends still work. This was the main regression risk and it's clean. - No new panics — the old
.expect()/.unwrap()/process::exitpaths (missingHOME, missingvar/version) are now properCliError→ exit 1 instead of a 101 panic. Strictly better. - uninstall / default semantics intact — symlink comparison,
--forcegating, realremove_dir_allbefore the success message, and version-exists validation are all preserved. - Tests tightened, not weakened — assertions moved from
contains()to exact stdout/stderr equality plus empty-stream checks, with the filesystem assertions retained. Every help page has aninstasnapshot (the oldsrc/bin/snapshotsset is fully superseded).
One thing worth a sanity check (not a blocker): cli::default() now marks <VERSION> required and the help reads Usage: sdk default <SDK> <VERSION>. The native binary always required it (required(true) on master too), so this just makes the help honest — but the version-less form (sdk default java) is a real feature of the bash default command, and master's help text documented it. If the bash wrapper ever routes to this help render, users lose that documentation. Low stakes.
Nit: sdk help --help / sdk help -h prints unknown command --help with a fuzzy suggestion rather than the help page — the help binary doesn't special-case a leading -. Harmless since the wrapper drives help, but a plausible manual keystroke.
Approving. 🦀
|
Turning this into a draft until we've ensured full compatibility with the sdkman-cli wrapper. |
Co-Authored-By: Claude <noreply@anthropic.com>
Binaries are flat files in src/bin/ since eda931d, and the package is not a workspace. Describe where each kind of test lives, the release script and the docs layout. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- gate: fmt check, clippy with -D warnings, test - snapshot rules for insta - boundaries for autonomous loops Co-Authored-By: Claude <noreply@anthropic.com>
- add pure colour_choice applying R4 env and config rules in order - add ui::init reading etc/config and setting the global ColorChoice
- add success, info, warning, error and hint message functions - add value and table data output plus sdk, cmd and path tokens - add CliError with a report method Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- known_candidates returns Result<Vec<String>, CliError>, dropping Box::leak - add require_candidate and require_version_path with catalogue error text
- give home fn main() -> ExitCode calling a run helper - emit the path through ui::value and errors through CliError
- add optional etc/config to VirtualEnv test harness - assert ANSI under CLICOLOR_FORCE and plain value, NO_COLOR and config off Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- route success, guards, warnings and file errors through ui/CliError - expose helpers::os_reason for file-error reasons Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- print the success line only after the change succeeds - route the copy fallback and file failures through ui and CliError Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- print one SDK default as an unstyled value and all as a table - route the no-default error and empty info through ui Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- print core: aligned with native: and brand via ui - replace version-file panics with CliError, exit 1 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- add strsim jaro scoring in require_candidate with a 0.7 threshold - hint "did you mean <sdk>?" or fall back to "sdk list" Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- add cli module with configure() styles, template and native builders - parse current, default, home, uninstall and version via try_get_matches - snapshot each native --help page Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- map clap parse errors to STYLE.md shapes on stderr with exit 2 - route -h/--help to stdout with exit 0 via clap's own print - reject extra arguments and unknown options for sdk version Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- build the sdk command from the native cli definitions and resolve sdk help <command> and its aliases with find_subcommand - assert sdk help <command> and <command> --help give identical stdout
- add cli builders for the bash commands and a sdk() main page - map an unknown command to error + closest suggestion, exit 2 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- drop the colored dependency and its two unused panic-based validators - remove textwrap, now unused since clap wraps help Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- note interim java 21.0.2-tem form and the sdk usage-line override - list the ui and cli modules in the architecture section Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- use Result::ok in read_file_content instead of a match - borrow sdkman_dir for env::set_var; use write_all in the test helper
- drop needless return and to_owned in the test harness - inline format args so clippy --all-targets passes
- render the sdk main page and rewrite clap's single-alias [alias: X] to the catalogue's [aliases: X] form - preserve the colour decision via anstream::stdout() Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- infer_sdkman_dir returns Result<PathBuf, CliError> - fallback_sdkman_dir errors with cannot find your home directory, exit 1 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- drops the last panic! and to_str().unwrap() in src/lib.rs Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- extract remove_current_link into helpers - call it from default and uninstall Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- call require_candidate with an unknown name - assert the unknown SDK message and did-you-mean hint Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- add a sdk default missing-argument test asserting exit 2 - assert the full parse-error lines and --help hints for sdk version Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
- no native help when native commands are disabled - keep clap's two-line layout for full help pages - pin flag position and stderr assertions in tests Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
- add bin_output as the single place that sets colour env - drop duplicate short main-page test Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
a73f656 to
33c79a5
Compare
Summary
Aligns all native subcommands on a shared output-styling architecture so user-facing text is consistent, stream-aware, and sourced from single definitions. Also makes the
helpbinary answer every help flag the bash core forwards to it, so that with native commands enabled all help is rendered by native code.Output style alignment (spec 001)
uimodule as the sole place that writes messages and applies styling — message types, data output, semantic tokens, andCliError(ADR 0003: stdout for data, stderr for everything conversational).climodule holding sharedclapcommand definitions so each command's help has one source of truth, and rebuilds thehelpbinary on top of those definitions.current,default,home,uninstall, andversionto a commonrunshape withui-based output.clapparse errors and maps unknown bash commands to styled help.[aliases: X].helpers: returnsResultfrom shared helpers, reports a missing home directory instead of panicking, shares current-link removal, and removes dead code.coloredandtextwrapdependencies in favour ofanstream/anstyle.STYLE.mdandCLAUDE.md, clears pre-existing clippy lints, and expands test coverage (includinginstasnapshots for every help page).Help flags through the core (spec 002)
helpaccepts-hand--help:-halways prints the short page and--helpthe full page, for the main page and every command in the Help Catalogue.help -h,help --help,help <cmd> -handhelp <cmd> --helpfollow the contract the bash core relies on; when both flags are given, the last one wins.flushpage, which described behaviour bashflushdoes not have.las a hidden alias oflist.-h/--helpmatchhelp.helpbinary, lands separately insdkman-cli.Docs
CLAUDE.mdthat a later spec overrides an earlier one.Test plan
cargo fmt --checkcargo clippy --all-targets -- -D warningscargo test🤖 Generated with Claude Code