Skip to content

Join map-source slice values with the command separator - #2549

Open
joshbarros wants to merge 2 commits into
urfave:mainfrom
joshbarros:fix/2516-map-source-slice
Open

joshbarros wants to merge 2 commits into
urfave:mainfrom
joshbarros:fix/2516-map-source-slice

Conversation

@joshbarros

@joshbarros joshbarros commented Nov 17, 2026 •

Copy link
Copy Markdown

Fixes #2516

NewMapValueSource formatted a list with %+v, so slice flags received a single value like "[80 443]" and failed to parse, or a StringSliceFlag got one element "[a b]" instead of two.

For slice and array values, join the elements with the owning command's effective SliceFlagSeparator (comma by default), including through nested ValueSourceChain values. Slice flags therefore receive separate elements, and elements containing commas stay intact when a non-comma separator is configured. Scalar values keep the existing formatting.

Adds tests for the default separator, a custom separator with comma-containing elements, and a nested source chain. go test ./... passes.

NewMapValueSource formatted a list with %+v, so slice flags received one value like "[80 443]" instead of separate elements. Join slice and array values with commas, matching the command-line and cli-altsrc behavior; update the map source expectation.
@joshbarros
joshbarros requested a review from a team as a code owner November 17, 2026 09:46
Map-backed slice values now join elements with the owning command's effective SliceFlagSeparator, including when the source is wrapped in a nested ValueSourceChain. This keeps elements containing commas intact when a different separator is configured.
@joshbarros joshbarros changed the title Join map-source slice values with commas Join map-source slice values with the command separator Nov 17, 2026

This branch has not been deployed

No deployments
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.

NewMapValueSource passes a list to slice flags as "[a b]"

1 participant