Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add map support #5

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

add map support #5

wants to merge 3 commits into from

Conversation

seebs
Copy link
Contributor

@seebs seebs commented Dec 5, 2018

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.

seebs added 3 commits December 4, 2018 15:08
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.
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.

1 participant