Keep empty and dash operands with runnable parents

This commit is contained in:
2026-10-20 01:07:23 +00:00
parent 5c26d80228
commit e47ae799d7
3 changed files with 93 additions and 3 deletions

View File

@@ -1,6 +1,6 @@
# Alias interaction audit remediation
Status: in progress; completed findings are marked individually below.
Status: complete; R-1 through R-3 are addressed and marked individually below.
## Review scope and evidence
@@ -140,7 +140,7 @@ passed on Go 1.26.8.
## R-3: Preserve empty and dash operands before child-name tokens
Status: open. Priority: P2. Category: inherited parser/routing inconsistency.
Status: complete. Priority: P2. Category: inherited parser/routing inconsistency.
**Evidence:** [Session.Parse](../../internal/cobra/parse.go#L55) gives the entire
leading non-option token sequence to Cobra's `Find`. Cobra's command search
@@ -186,3 +186,13 @@ values, and expose parent invocation paths. Cover parent-local flag aliases and
help on the same inputs, plus genuine child selection and ordinary terminator
behavior. Tests should establish CommandKit's boundary, not depend on a specific
replacement routing algorithm or backend type.
**Completed:** The adapter ends command search before empty or single-dash
operand tokens, preserving them and subsequent tokens for the parent's ordinary
flag/operand parser. All four canonical/alias regressions failed before the fix
and now preserve the ordered operands, parent-local flag aliases, and invocation
paths. The same cases cover metadata-only parent help and explicit terminators;
immediate child selection remains intact. No syntax restriction or public API
was added. Final uncached offline suites passed on Go 1.26.8: root with the
workspace disabled, plus both integrations and their maintained examples in the
existing workspace against the local core.