Datetime type support for click.
Project description
Click Datetime
Click support for Python's datetime
types to allow developers to easy parse
date strings as parameters to Python click CLIs.
Example
You can accept a datetime as a parameter to your click CLI
from datetime import datetime
import click
from click_datetime import Datetime
@click.option(
"--date",
type=Datetime(format="%Y-%m-%d"),
default=datetime.now(),
help="An example parsing and printing a datetime.",
)
@click.command()
def cli(date: datetime):
click.echo("The date : {0}".format(date))
if __name__ == "__main__":
cli() # type: ignore
$ python main.py --date=2016-01-01
Installation
pip install click-datetime
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_datetime as cd; print(dir(cd))'
Authors
- Dawson Reid (@ddaws)
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_datetime-0.4.0.tar.gz
(1.7 kB
view hashes)
Built Distribution
Close
Hashes for click_datetime-0.4.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dfd2f54142f0f899535e400946d724cc8319b4cf70d110d1451f892a6f010b04 |
|
MD5 | fd68acad5cad9492c0831106ffb94b6d |
|
BLAKE2b-256 | c9aa3272aefc8d18b14ba7fe6c34ca683bb9a13f05d6280be9839e139b14ea92 |