Skip to content

Is there any way to use field in macro attribute declaration? #3331

Answered by epage
hzqd asked this question in Q&A
Discussion options

You must be logged in to vote

No, this won't work. What the macro expands out to is a CLI definition followed by a parse phase. One reason we can't make syntax like this work is that default_value is used for help text and we might not be able to instantiate Args to access input when help is shown. Even if we instead make this about referencing the intermediate value as we build up Args, there are still cases where input won't exist (e.g. $ cmd --help).

In #3008, we are looking at exploring custom runtime default logic that also allows a user to provide custom help hints which would enable something like this.

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by hzqd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants