-
-
Notifications
You must be signed in to change notification settings - Fork 64
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
Support for suppressing fields from the CLI --help message #431
Comments
@kschwab Please take a look when you have time. |
@Geo5, I presume just like class Settings(BaseSettings):
field: CliSuppress[int] = Field(description='Hide this field from help') This is not hard to add, I can put up a PR if the above looks reasonable. Obviously, "field" still gets parsed at the CLI and is only hidden from CLI --help text. |
Yes exactly, it is only hidden from CLI --help, but still gets parsed. parser.add_argument("--foo", help=argparse.SUPPRESS if platform=="linux" else "This is the foo argument") |
That's a great point. I added support for both in #436. e.g.: class Settings(BaseSettings, use_attribute_docstrings=True):
field: CliSuppress[int]
"""Hide this field from help"""
foo: int = Field(description=CLI_SUPPRESS if platform=="linux" else "This is the foo argument") |
Looks great, thank you! |
In stdlib argparse you are able to set the help message to
argparse.SUPPRESS
to hide the entry from the generated--help
output.Would it be possible to support this in pydantic-settings as well?
It seems to work, if you add a
here https://github.com/pydantic/pydantic-settings/blob/main/pydantic_settings/sources.py#L1885
and setting the field description to
argparse.SUPPRESS
The text was updated successfully, but these errors were encountered: