Skip to content

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

License

Notifications You must be signed in to change notification settings

adamtheturtle/click-pathlib

Repository files navigation

Build Status codecov PyPI

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.

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

$ pip install click-pathlib

This supports Python 3.7+.

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()

Thanks to @jeremyh for describing this solution on GitHub at pallets/click#405 (comment).

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