https://github.com/markusgrotz/click-prompt
interactive command line options for the click library
https://github.com/markusgrotz/click-prompt
cli python
Last synced: 5 months ago
JSON representation
interactive command line options for the click library
- Host: GitHub
- URL: https://github.com/markusgrotz/click-prompt
- Owner: markusgrotz
- License: mit
- Created: 2022-08-01T04:36:56.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2025-12-22T13:05:37.000Z (6 months ago)
- Last Synced: 2026-01-05T12:02:52.711Z (6 months ago)
- Topics: cli, python
- Language: Python
- Homepage:
- Size: 3.67 MB
- Stars: 9
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
README
# click-prompt
[](https://pypi.org/project/click-prompt/)
[](https://pypi.org/project/click-prompt/)
[](https://github.com/markusgrotz/click-prompt/blob/main/LICENSE.md)
[](https://github.com/astral-sh/ruff)
[](https://pepy.tech/project/click-prompt)
**click-prompt** extends the [Click](https://click.palletsprojects.com/) 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](https://stackoverflow.com/questions/54311067/).
Contributions are welcome! [Open a pull request](https://github.com/markusgrotz/click-prompt/pulls) or [submit an issue](https://github.com/markusgrotz/click-prompt/issues).
## Installation
To install `click-prompt`, use pip:
```bash
pip install click-prompt
```
## Usage
Here’s a basic example using the `choice_option` decorator:
```python
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](https://github.com/markusgrotz/click-prompt/blob/main/example.py).

## 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](https://github.com/markusgrotz/click-prompt/blob/main/LICENSE.md) file for more information.