Skip to content

adamtheturtle/click-pathlib

Repository files navigation

Build Status codecov PyPI

Deprecation Notice

DEPRECATED

This package is no longer needed with Click >= 8.0.0. In those versions of Click, The Path param type can be passed: path_type=pathlib.Path to return a path object instead of a string.

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.7+.

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 pallets/click#405 (comment).

Contributing

See CONTRIBUTING.rst.

About

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

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published