Skip to main content

'A Python click type which is similar to click.Path but returns a pathlib Path'

Project description

Build Status codecov PyPI

Click Pathlib

A Python click type which is similar to click.Path but returns a Pathlib.Path.

Installation

$ pip install click-pathlib

This supports Python 3.8+.

Usage

Use the click_pathlib.Path just like a click.Path type and your function will receive a pathlib.Path.

import click
import click_pathlib

@click.command('delete')
@click.argument(
    'existing_file',
    type=click_pathlib.Path(exists=True),
)
def delete(existing_file):
    existing_file.unlink()

Credits

Thanks to @jeremyh for describing this solution on GitHub at https://github.com/pallets/click/issues/405#issuecomment-470812067.

Contributing

See CONTRIBUTING.rst.

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-pathlib-2020.3.13.0.tar.gz (15.6 kB view hashes)

Uploaded Source

Built Distribution

click_pathlib-2020.3.13.0-py3-none-any.whl (3.6 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page