Open
Conversation
It turns out that newPrefix always ends up being the same as flagName; in the case where there's an existing prefix, flagName was already set to "prefix + flagName". Which means that, if something is double-nested, the name got appended twice. Also add a corresponding test case.
This is a bit clunky and possibly just plain a bad idea, but I got really curious about whether it could be done. Answer: Yes. The difficulty in supporting maps is (1) making sure we can find names for them, (2) handling assignments to them, since their contents aren't addressable. So we require that keys either be string or satisfy Stringer, and we build a table of known map-member arguments, and build a followup pass to come back and assign those back over. This only works with Run/RunArgs. The Flags function isn't changed, and won't support the new feature, but FlagsMap could in theory -- it returns a cleanup function to call to do the map assignments. This is probably a bad idea.
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.
This is probably sorta insane, I just wanted to see if it could be done.
Map members only define arguments for entries they have when the provided structure-or-map was scanned to create arguments.