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 Code style PyPI - Downloads

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.6.5.tar.gz (4.7 kB view details)

Uploaded Source

Built Distribution

click_prompt-0.6.5-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for click_prompt-0.6.5.tar.gz
Algorithm Hash digest
SHA256 eb493274fe4415ddd2ec9f6dc2706fa9dc16b72e6982d1f621b1e370e3d46345
MD5 6e469676f5d646d0ead333e56f9b15cc
BLAKE2b-256 3417addbe2d5058d3368f48679d757e32954dfd831b8c46c423ac88e7dfabf5a

See more details on using hashes here.

Provenance

The following attestation bundles were made for click_prompt-0.6.5.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.6.5-py3-none-any.whl.

File metadata

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

File hashes

Hashes for click_prompt-0.6.5-py3-none-any.whl
Algorithm Hash digest
SHA256 de2b95dc99acbf3ec73b59efa6a576711a8ba4bbfb8abc1f621027b73dcefba4
MD5 7cd0d88f49533b98b515ef2e78d6a1c6
BLAKE2b-256 107e5dca1309a4c938cad3a98c1443725291306fc9428e600388a792922def17

See more details on using hashes here.

Provenance

The following attestation bundles were made for click_prompt-0.6.5-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 Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page