Skip to main content

click-prompt provides more beautiful interactive options for the Python click library

Project description

click-prompt

Supported Python Versions PyPI version License Ruff Downloads/Month

click-prompt extends the Click command-line interface library by adding intuitive, interactive prompts. It's perfect for building more user-friendly CLI tools.

This library is inspired by a post on stackoverflow.com.

Contributions are welcome! Open a pull request or submit an issue.

Installation

To install click-prompt, use pip:

pip install click-prompt

Usage

Here’s a basic example using the choice_option decorator:

import click
from click_prompt import choice_option

@click.command()
@choice_option('--fruit', type=click.Choice(['Apples', 'Bananas', 'Grapefruits', 'Mangoes']))
def select_fruit(fruit: str):
    """Prompt user to select a fruit from a list."""
    print(f"You selected: {fruit}")

if __name__ == '__main__':
    select_fruit()

Example

For more examples see the file example.py.

Example

Available Decorators

Each of these decorators replaces a click.Option (and also works with click.Argument):

  • choice_option
    Prompt the user to select one (or more with multiple=True) from a list.

  • confirm_option
    Yes/No confirmation prompt.

  • filepath_option
    Prompt the user to select a file path with auto-completion.

  • auto_complete_option
    Input prompt with tab completion from a list of choices.

  • input_text_option
    Prompt the user for free-form text input.

License

This project is licensed under the MIT License. See the LICENSE file for more information.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

click_prompt-0.7.1.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

click_prompt-0.7.1-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

Details for the file click_prompt-0.7.1.tar.gz.

File metadata

  • Download URL: click_prompt-0.7.1.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for click_prompt-0.7.1.tar.gz
Algorithm Hash digest
SHA256 4558d2d3a8a7e0187fa3ab6b2cc0bfa0c1d7d840245d64fbe09060eba94a9fc8
MD5 2fd3ec75e02e4be7977c1ef684077f63
BLAKE2b-256 b2ea8068615f5fd6ed1e3de0f566be63f21bbc8fa1bd24dd26b118d69ffd786d

See more details on using hashes here.

Provenance

The following attestation bundles were made for click_prompt-0.7.1.tar.gz:

Publisher: publish-to-test-pypi.yml on markusgrotz/click-prompt

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file click_prompt-0.7.1-py3-none-any.whl.

File metadata

  • Download URL: click_prompt-0.7.1-py3-none-any.whl
  • Upload date:
  • Size: 8.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for click_prompt-0.7.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0ab0e80493d7ad9cb71cfd3903319bbea964b0e190e7f3db21ea03ba2935448f
MD5 61f576ab6e05f3ae3850af25efc50ab5
BLAKE2b-256 02096091b944bb39224d8ba66202f85a3441405e08e0f8fccef7117e89d18405

See more details on using hashes here.

Provenance

The following attestation bundles were made for click_prompt-0.7.1-py3-none-any.whl:

Publisher: publish-to-test-pypi.yml on markusgrotz/click-prompt

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page