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.
clickhas 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.argumentparameters and let the library do all the magic and checking for me:The only inconvenience I had - it did not return a
pathlib.Pathobject, so I had do manually create it, but that is not a big deal.As I can see,
click.Pathtype is not exposed in thetypermodule. And usingpathlib.Pathas 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.