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

Export tag.items -> tag.Items #471

Closed
wants to merge 1 commit into from
Closed

Conversation

miekg
Copy link

@miekg miekg commented Nov 22, 2024

This makes item public, so that consumers can see their own tags. This helps (e.g.) building completion generators that want to use their custom tags on the struct.

Taking a *kong.Node as n, and:

for i, f := range n.Flags {
        fmt.Printf("%d %v\n", i, f.Tag.Items["completion"])
}

shows the value of the (custom) completion tag.

This makes item public, so that consumers can see their own tags. This
helps (e.g.) building completion generators that want to use their
custom tags on the struct.

Taking a *kong.Node as n, and:
~~~ go
for i, f := range n.Flags {
        fmt.Printf("%d %v\n", i, f.Tag.Items["completion"])
}
~~~

shows the value of the (custom) completion tag.

Signed-off-by: Miek Gieben <miek@miek.nl>
@miekg
Copy link
Author

miekg commented Nov 22, 2024

Closes: #470

@alecthomas
Copy link
Owner

Why did tag.Get() not suffice?

@miekg
Copy link
Author

miekg commented Nov 22, 2024

Why did tag.Get() not suffice?

that did not gave me tags that kong didn't know about. But now that I have an easy way to test I'll double check.

@miekg
Copy link
Author

miekg commented Nov 22, 2024

Yep that also works.

Maybe this is a documention issue? Or maybe it's me. Closing this and the issue as this works with the current code.

Thanks for your help.

@miekg miekg closed this Nov 22, 2024
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.

2 participants