Skip to content

fix: do not decode mapper defaults for unselected commands - #667

Open
hindessm wants to merge 1 commit into
alecthomas:masterfrom
hindessm:mrh/fix-mapper-defaults
Open

hindessm wants to merge 1 commit into
alecthomas:masterfrom
hindessm:mrh/fix-mapper-defaults

Conversation

@hindessm

Copy link
Copy Markdown
Contributor

When a named mapper (or any custom MapperFunc) is registered and multiple commands share that mapper type with a default tag, parsing one command causes the mapper to be invoked for the default values of every sibling command as well.

In Context.Reset(), check whether each value belongs to the selected command path before calling value.Reset(). Values outside that path are simply zeroed — no mapper is invoked.

This should resolve #666.

When a named mapper (or any custom `MapperFunc`) is registered and multiple
commands share that mapper type with a `default` tag, parsing one command
causes the mapper to be invoked for the **default values of every sibling
command** as well.

In `Context.Reset()`, check whether each value belongs to the selected
command path before calling `value.Reset()`. Values outside that path are
simply zeroed — no mapper is invoked.
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.

NamedMapper uses defaults from non-selected commands

2 participants