Repository navigation
fix: preserve incomplete short groups for shell completion - #2485
Open
kimjooyoon wants to merge 1 commit into
Open
kimjooyoon wants to merge 1 commit into
kimjooyoon wants to merge 1 commit into
Conversation
Authored with Codex. Keep pending grouped tokens available to custom completion callbacks, matching the existing single-flag behavior.
This branch has not been deployed
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.
What type of PR is this?
What this PR does / why we need it:
With
UseShortOptionHandlingenabled, custom shell completion loses an unfinished grouped flag fromcmd.Args(). For example, declare booleanaand stringb, then run:A
ShellCompletecallback readingcmd.Args().Slice()currently receives only["value"]. After this change it receives["value", "-ab"], matching the existing handling of an unfinished single flag such as-b.command_parse.goretains the unparsed tail during shell completion when a short group contains an unknown flag, or its final value-taking flag has no value yet. Normal invocations still return their original errors. Complete groups, including an explicit empty value (-ab=), remain consumed normally.completion_short_group_test.gochecks the callback at the root, child and nested command, with unknown groups and missing ASCII/Unicode final values. It also checks normal errors, parsed values, explicit empty values and that completion does not execute the action.Which issue(s) this PR fixes:
Independently reproduced on main
10f69fd3c38de86a3bc17810dcb7f818b494f027; no existing matching issue or open PR found in the search before submission.Special notes for your reviewer:
Authored and tested with a Codex agent on behalf of kimjooyoon. This change adds no dependency and changes no public API. It extends the existing single-flag completion behavior to grouped short flags.
Testing
Local macOS arm64:
go test ./...,go test -tags urfave_cli_no_template ./..., andgo test -race ./...pass.make generate vet check-binary-size v3diffpasses; generated public API files remain unchanged.make gfmrunpasses the README example check with pinned gfmrun v1.3.3.Upstream test CI passes all six Linux/macOS/Windows × stable/oldstable jobs, and lint CI passes, both on head
5dbdb1037281c390c4f98c144ab82150262bdff9. These passing checks do not assert maintainer review or acceptance.Release Notes