这是indexloc提供的服务,不要输入任何密码
Skip to content

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