Click Integration¶
This is probably what you're all here for! prompts.py lets you drop it's pretty prompts right into an existing CLI using Click, with a few limitations. This can be done by passing the PrettyOption class to click.option.
Note
If you're using Click, you probably have it installed. However, if by some miracle you don't, install prompts.py with the click optional dependency:
For example:
from prompts.integration import PrettyOption
import click
@click.command()
@click.option(
"--name",
prompt='What is your name?',
cls=PrettyOption,
)
def main(name: str):
print(f"Hello, {name}")
if __name__ == "__main__":
main()
This has a few limitations as of now:
hide_inputis unsupportedshow_choicesis unsupportedconfirmation_promptis unsupportedvalue_procis unsupported
However, on the bright side, flags, defaults, and custom prompt strings are all supported!