Fix --help on a non-first subcommand showing wrong help (#586)#587
Open
Sootopolis wants to merge 1 commit into
Open
Fix --help on a non-first subcommand showing wrong help (#586)#587Sootopolis wants to merge 1 commit into
Sootopolis wants to merge 1 commit into
Conversation
Subcommands.parse passed the parent's CliConfig (finalCheckBuiltIn = true) when parsing the child OrElse, so a non-matching alternative ran exhaustiveSearch and returned its own help, short-circuiting before the named subcommand was tried. Use childConf (finalCheckBuiltIn = false), as the sibling help/wizard paths already do, so a mismatch fails as CommandMismatch and OrElse advances to the correct subcommand. Closes zio#586 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Closes #586.
Problem
root <sub> --helpshowed the first registered subcommand's help instead of the named one, for every non-first subcommand (and nested cases). Root--helpwas fine.Fix
Subcommands.parseparsed the childOrElsewith the originalconf(finalCheckBuiltIn = true) in theUserDefinedbranch. A non-matching alternative then ranexhaustiveSearch, returned its own help as a success, and short-circuited theOrElsebefore the named subcommand was tried. Switched that one call to the existingchildConf(finalCheckBuiltIn = false) — already used in the sibling help/wizard paths in the same method — so a mismatch fails asCommandMismatchandOrElseadvances to the correct subcommand.Test
Added a regression test under the
issue #448suite:tool stop --helpmust showstop's help and not the first subcommand's. Verified RED onmaster(leaked the first subcommand's option) before the fix.zioCliJVM/testOnly zio.cli.CommandSpeczioCliJS/testOnly zio.cli.CommandSpeczioCliNative/testOnly zio.cli.CommandSpecsbt fmt/sbt check