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

Dynamically Hide Flags with Variables #316

Open
maaslalani opened this issue Jul 12, 2022 · 1 comment
Open

Dynamically Hide Flags with Variables #316

maaslalani opened this issue Jul 12, 2022 · 1 comment

Comments

@maaslalani
Copy link

maaslalani commented Jul 12, 2022

Hey! This is a fantastic project that I am using to build a new command-line application and it is working really well so far, and I am very much enjoying using it.

I have a bit of a complex use case that I wanted to ask if was reasonable to introduce some logic for.

Essentially, I have LOTS of flags that I am reusing and composing for different commands and sometimes I want to hide them since they can get noisy and potentially only show the sub-flags that are relevant instead of all of the flags in the struct.

I was wondering if it is reasonable to allow the hidden:"" value of a flag property to take a boolean so that it is possible to dynamically hide flags as it is possible to dynamically set their default values.

My thinking is that then you could use variables to hide:"${flagHidden}" and set the variables in the parent struct so that it's possible to dynamically hide flags. To avoid breaking changes I am guessing we would do the following logic:

  1. If hidden:"" tag is present hide the flag / cmd, etc...
  2. If hidden:"true" is set to true hide the flag / cmd, etc...
  3. If hidden:"false" is set to false don't hide the flag.

What do you think about this? I'd suggest we implement this only if it is not too complicated as I can work around this by creating different structs with different tags and using them but it would be super nice if this logic worked as described above 😄

@alecthomas
Copy link
Owner

Glad you're enjoying Kong :)

Your proposal eems reasonable to me. I think generalising this to any "boolean" tag would be useful too.

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

No branches or pull requests

2 participants