Skip to content

[FEATURE] Handling Path / File arguments easily #2

Description

@senpos

click has an opportunity to handle Path and File arguments with ease.
Is there an option to do the same in typer?

I am not gonna lie, that was so fun to just put this into the click.argument parameters and let the library do all the magic and checking for me:

@click.command()
@click.argument(
    "filename",
    type=click.Path(exists=True, dir_okay=False, resolve_path=True, readable=True),
)
def path_command(filename):
    ...

The only inconvenience I had - it did not return a pathlib.Path object, so I had do manually create it, but that is not a big deal.

As I can see, click.Path type is not exposed in the typer module. And using pathlib.Path as a type for my parameter is not helping in any way.

Thanks for your time! I would like to know what you think about it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureNew feature, enhancement or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions