mosquito / argclass

A wrapper around the standard argparse module that allows you to describe argument parsers declaratively
Apache License 2.0
12 stars 3 forks source link

Do not Print Defaults for Long Secrets #13

Closed daskol closed 1 year ago

daskol commented 1 year ago

Printing long values and secrets in particular seems to be an anti-pattern. It would be great to at least mask secrets somehow See example below.

$ ./run.py --help
usage: run.py [-h] [--openai-chatgpt-token OPENAI_CHATGPT_TOKEN]

options:
  -h, --help            show this help message and exit
  --openai-chatgpt-token OPENAI_CHATGPT_TOKEN
                        (default: DCBPBteVeXRoUlzMurGxWpwAIcRjGOmnWrkoNBVhjeNvPVunfu
                        KHeGpllxeTfemZZdnxOVAlfWehVuBJBozGKeiIqwvyjtjfJzwKBVhjeNBVhjeN
                        KHeGpllxeTfemZZdnxOVAlfWehVuBJBozGKeiIqwvyjtjfJzwKBVhjeNBVhjeN
                        KHeGpllxeTfemZZdnxOVAlfWehVuBJBozGKeiIqwvyjtjfJzwKBVhjeNBVhjeN
                        KHeGpllxeTfemZZdnxOVAlfWehVuBJBozGKeiIqwvyjtjfJzwK) [ENV:
                        OPENAI_CHATGPT_TOKEN]

Default values will based on following configuration files ['chatgpt.ini']. Now 1
files has been applied ['...../chatgpt.ini']. The configuration files is INI-formatted files where
configuration groups is INI sections.See more
https://pypi.org/project/argclass/#configs
mosquito commented 1 year ago

May be add the "secret" argument and do not print default anymore?

daskol commented 1 year ago

What is it? A type, a keyword argument?

mosquito commented 1 year ago

I imagine this like keyword argument. But your question really useful. May be argclass.Secret will be good enough. Or it's might be a shortcut for argclass.Argument(..., secret=True), anyway right now I'm on vacation, if you want to implement it your are welcome.

daskol commented 1 year ago

I see what I can do.