trogon icon indicating copy to clipboard operation
trogon copied to clipboard

feat: Added support for hidden inputs

Open Aradhya-Tripathi opened this issue 2 years ago • 8 comments

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 avatar May 28 '23 13:05 Aradhya-Tripathi

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.

darrenburns avatar Jun 06 '23 10:06 darrenburns

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?

Aradhya-Tripathi avatar Jun 12 '23 06:06 Aradhya-Tripathi

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.

darrenburns avatar Jun 12 '23 13:06 darrenburns

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 ⚡

Aradhya-Tripathi avatar Jun 14 '23 07:06 Aradhya-Tripathi

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 avatar Jun 20 '23 17:06 fresh2dev

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.

fresh2dev avatar Jun 23 '23 16:06 fresh2dev

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

derlin avatar Jun 23 '23 16:06 derlin

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

https://github.com/Textualize/trogon/pull/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

:crossed_fingers:

fresh2dev avatar Jun 23 '23 22:06 fresh2dev