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

feat: Added support for hidden inputs #32

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

Aradhya-Tripathi
Copy link
Contributor

Hidden Input support

Hiding input in TUI when hide_input=True for an option

@click.option("--foo", hide_input=True)
def exec(foo):
     ...

@Aradhya-Tripathi Aradhya-Tripathi marked this pull request as ready for review May 28, 2023 16:55
@darrenburns
Copy link
Member

Thanks for this!

Does it make sense to have hide_input on options that don't have prompt? My gut feeling is that hide_input is not something that Trogon should handle at all, since it's Click that will accept the input for it.

I think if the option has prompt=True or hidden=True, then we should just not render any widget for it in the form.

@Aradhya-Tripathi
Copy link
Contributor Author

Thanks for this!

Does it make sense to have hide_input on options that don't have prompt? My gut feeling is that hide_input is not something that Trogon should handle at all, since it's Click that will accept the input for it.

I think if the option has prompt=True or hidden=True, then we should just not render any widget for it in the form.

Makes sense how about having something that gives info on hide_input flag for a command even if it isn't rendered then?

@darrenburns
Copy link
Member

I think hide_input doesn't make sense, since hide_input is something Click uses when prompt=True to hide the characters the user types. All of the prompt stuff is handled inside Click.

@Aradhya-Tripathi
Copy link
Contributor Author

I think hide_input doesn't make sense, since hide_input is something Click uses when prompt=True to hide the characters the user types. All of the prompt stuff is handled inside Click.

makes sense I'll change it ⚡

@fresh2dev
Copy link

Based on @darrenburns remarks, it would make the most sense that Trogon presented textboxes for these arguments that redacted user input; a textbox for secrets. Does Textual provide such a widget?

@fresh2dev
Copy link

Based on click docs, the proper way to handle these options is self-evident, IMO.

https://click.palletsprojects.com/en/8.1.x/api/#click.Option

hide_input (bool) – If this is True then the input on the prompt will be hidden from the user. This is useful for password input.

hidden (bool) – hide this option from help outputs.

@derlin
Copy link

derlin commented Jun 23, 2023

Will the hidden option also be tackled in this pr? My organisation can't wait to use trogon, but is blocked by #29

@fresh2dev
Copy link

fresh2dev commented Jun 23, 2023

I have a (hopefully temporary) fork of Trogon to make click an optional dependency.

#38

In this fork, I just implemented the ability for Trogon to:

  • omit hidden parameters and subcommands (when hidden=True)
  • show read-only input for required prompts (when prompt=True, prompt_required=True)
  • redact sensitive values (when hide_input=True) <-- This was tricky!

https://asciinema.org/a/0aa5accX2QcN2D8oFwyCYty69

🤞

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.

None yet

4 participants