Click Pendulum
Click support for Pendulum date, time, interval and duration types to allow developers to easily parse strings as parameters to Python click CLIs.
Example: pendulum.DateTime
You can accept a Pendulum DateTime as a parameter to your click CLI
import click, pendulum
from click_pendulum import DateTime
@click.option(
"--date",
type=DateTime(),
default=pendulum.now(),
help="An example parsing and printing a datetime.",
)
@click.command()
def cli(date: pendulum.DateTime):
click.echo("The date : {0}".format(date))
if __name__ == "__main__":
cli() # type: ignore
$ python examples/datetime_with_custom_format.py --date=2016-01-01
The date : 2016-01-01 00:00:00+00:00
Example: pendulum.Duration
You can accept a Pendulum Duration as a parameter to your click CLI
import click, pendulum
from click_pendulum import Duration
@click.option(
"--duration",
type=Duration(),
help="Parse a duration string.",
)
@click.command()
def cli(duration: pendulum.Duration):
click.echo(f"Duration: {duration}")
if __name__ == "__main__":
cli() # type: ignore
$ python examples/duration_parser.py --duration="2d5h"
Duration: 2 days 5 hours
pip install click-pendulum
Development
Building and packaging
poetry build
Testing the compiled wheel
# Create a virtual environment for testing
python -m .venv/test
source .venv/test/bin/activate
# Confirm importing and exporting is correct
python -c 'import click_pendulum as cd; print(dir(cd))'
Authors
- Dawson Reid (@ddaws)
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
click_pendulum-0.2.1.tar.gz
(2.5 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file click_pendulum-0.2.1.tar.gz.
File metadata
- Download URL: click_pendulum-0.2.1.tar.gz
- Upload date:
- Size: 2.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
poetry/1.8.3 CPython/3.12.4 Linux/6.6.44-1-MANJARO
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
18ae6b6d99e7f6c86128d07e7659997cd7a361495e5165861cb58dc688b557b0
|
|
| MD5 |
8df04f5c5089ab7da20e2886f7cde762
|
|
| BLAKE2b-256 |
48281b77617656b1d09d2702ecfafadc034ecf0b1e6458e8594ec57f6d220e58
|
File details
Details for the file click_pendulum-0.2.1-py3-none-any.whl.
File metadata
- Download URL: click_pendulum-0.2.1-py3-none-any.whl
- Upload date:
- Size: 3.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
poetry/1.8.3 CPython/3.12.4 Linux/6.6.44-1-MANJARO
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
12055375d93280efebe7837ec85bcb0f6f7b33232eecefb4886011f3f383af0e
|
|
| MD5 |
eb0ef6d4219c262be2aa0f2f5540cf5f
|
|
| BLAKE2b-256 |
28b0386103cd8094da0189b9dda0364ef34830a2b46e74fece965117067f119f
|