Skip to content

File option - prompting with pretty default? #914

@mvolfik

Description

@mvolfik

Hello,
I'm developing simple script, but I have found horrible default when using a file option with prompting with default value...
I have this code:

import click
import os.path
@click.command()
@click.option('-f', default=os.path.realpath("subdir/file.txt"), prompt="Please provide a file", type=click.File('rt'))
def func(f):
    pass
func()

But when I call it, it produces prompt like this:

me@computer:~/directory$ python3 script.py
Please provide a file [<_io.TextIOWrapper name='/home/me/directory/subdir/file.txt' mode='rt' encoding='UTF-8'>]:

Is this solved anywhere or how difficult would it be to fix it, so it would show [/home/me/directory/subdir/file.txt]?

Ubuntu 16.04 LTS 32-bit, Python 3.5.2, click 6.7

Please excuse any imperfections of this issue, I'm quite new to GitHub and haven't written any issues yet...

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions