Right now I have flask-script command that takes a path as an argument, then reads from the path:
@manager.option('-f', '--file', dest='file_path')
def my_command(file_path):
open(file_path)
...
I'd want it to be able to read from standard in as well. (I frequently need to pass it text on the clipboard, and it's annoying to have to create a file each time.)
How can I accomplish this?
I've tried using fileinput.input()
, via this https://stackoverflow.com/a/1454400/1164573, invoked with the following:
cat << EOF | ./manage.py my_command
abc
def
ghi
EOF
But fileinput.input()
is empty. Is this because flask-script is wrapping my function and not exposing standard in to it directly? How can I get around this?