click-prompt provides more beautiful interactive options for the Python click library
Project description
click-prompt
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.
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 withmultiple=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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
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
Algorithm | Hash digest | |
---|---|---|
SHA256 |
eb493274fe4415ddd2ec9f6dc2706fa9dc16b72e6982d1f621b1e370e3d46345
|
|
MD5 |
6e469676f5d646d0ead333e56f9b15cc
|
|
BLAKE2b-256 |
3417addbe2d5058d3368f48679d757e32954dfd831b8c46c423ac88e7dfabf5a
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1
-
Predicate type:
https://docs.pypi.org/attestations/publish/v1
-
Subject name:
click_prompt-0.6.5.tar.gz
-
Subject digest:
eb493274fe4415ddd2ec9f6dc2706fa9dc16b72e6982d1f621b1e370e3d46345
- Sigstore transparency entry: 234525251
- Sigstore integration time:
-
Permalink:
markusgrotz/click-prompt@d1542bf12d3276b102388e900c8a345dd6f5a34c
-
Branch / Tag:
refs/tags/v0.6.5
- Owner: https://github.com/markusgrotz
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com
-
Runner Environment:
github-hosted
-
Publication workflow:
publish-to-test-pypi.yml@d1542bf12d3276b102388e900c8a345dd6f5a34c
-
Trigger Event:
push
-
Statement type:
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
Algorithm | Hash digest | |
---|---|---|
SHA256 |
de2b95dc99acbf3ec73b59efa6a576711a8ba4bbfb8abc1f621027b73dcefba4
|
|
MD5 |
7cd0d88f49533b98b515ef2e78d6a1c6
|
|
BLAKE2b-256 |
107e5dca1309a4c938cad3a98c1443725291306fc9428e600388a792922def17
|
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
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1
-
Predicate type:
https://docs.pypi.org/attestations/publish/v1
-
Subject name:
click_prompt-0.6.5-py3-none-any.whl
-
Subject digest:
de2b95dc99acbf3ec73b59efa6a576711a8ba4bbfb8abc1f621027b73dcefba4
- Sigstore transparency entry: 234525257
- Sigstore integration time:
-
Permalink:
markusgrotz/click-prompt@d1542bf12d3276b102388e900c8a345dd6f5a34c
-
Branch / Tag:
refs/tags/v0.6.5
- Owner: https://github.com/markusgrotz
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com
-
Runner Environment:
github-hosted
-
Publication workflow:
publish-to-test-pypi.yml@d1542bf12d3276b102388e900c8a345dd6f5a34c
-
Trigger Event:
push
-
Statement type: