Skip to content

fix(cli): stop activating scenarios for help and version output - #187

Merged
ShortArrow merged 1 commit into
mainfrom
fix/quiet-metadata-commands
Aug 25, 2026
Merged

fix(cli): stop activating scenarios for help and version output#187
ShortArrow merged 1 commit into
mainfrom
fix/quiet-metadata-commands

Conversation

@ShortArrow

Copy link
Copy Markdown
Owner

ivicli --version could print this first:

[10:17:42 WRN] could not load active scenario ghost-scenario for device dut: ignored
0.3.1+66bd897…

Anything reading the version out of that output gets the warning line. Noticed while installing through mise, where the surrounding tooling made it obvious.

Cause

ActivateScenarioIfRequested ran before root.Parse(args). The comment explaining why — "so visa subcommands see the scenario on this same invocation" — is a good reason to activate early, but not a reason to activate before knowing what the invocation is. --version, --help, and a command line that does not parse never open a session, so reading the scenario store for them buys nothing and can only add noise.

Fix

Parse first, then decide. Parsing has no side effects, and the resulting ParseResult is invoked directly afterwards rather than re-parsed.

ScenarioActivation.IsNeededFor asks the parser what it resolved rather than matching raw tokens: Action is HelpAction covers --help at every level, a VersionOption result covers --version (its action type is not public, so the option is the handle), and Errors.Count > 0 covers a line that will not run. An argument that merely looks like --version therefore still activates — pinned by a test.

Also correct, and worth noting because it surprised me while writing the test: a bare group such as ivicli visa prints its own help, so it resolves to HelpAction and skips activation too.

Evidence

Not just "the warning is gone" — that could mean activation broke everywhere. With the same planted session.json naming a scenario that does not exist:

$ ivicli visa list          # still activates, still warns
[10:17:42 WRN] could not load active scenario ghost-scenario for device dut: ignored
(no devices configured)

$ ivicli --version          # no longer activates
0.3.1+66bd897…

Nine unit tests over the predicate, mutation-checked: removing the HelpAction branch fails four of them. Full CLI suite 125/125.

Activation ran before the command line was parsed, so an unloadable
binding in session.json printed a warning ahead of ivicli --version and
broke anything reading that output.
@ShortArrow
ShortArrow merged commit eeb2965 into main Aug 25, 2026
11 checks passed
@ShortArrow
ShortArrow deleted the fix/quiet-metadata-commands branch August 25, 2026 01:21
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.

1 participant