-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Closed
Description
Using click 6.7 + Python 3.6.0 :: Anaconda custom (64-bit)
If I create option with parameters type=click.File('w') default='-'
Then the value defaults to sys.stdout
. But when I create it with type=click.File('x') default='-'
it defaults to sys.stdin
. In my opinion it should default also to sys.stdout
becase x
file mode is also for writing (with exclusive file creation).
Run this script for proof:
#!/usr/bin/env python3
import sys
import click
@click.command()
@click.option('--file', '-f', type=click.File('x'), default='-')
def cli(file):
print('stdin:', file == sys.stdin)
print('stdout:', file == sys.stdout)
if __name__ == '__main__':
cli()
Output is:
$ ./test.py
stdin: True
stdout: False
Metadata
Metadata
Assignees
Labels
No labels