google / python-fire

Python Fire is a library for automatically generating command line interfaces (CLIs) from absolutely any Python object.
Other
27.18k stars 1.45k forks source link

support for - as parameter #15

Open ibeex opened 7 years ago

ibeex commented 7 years ago

as stated here https://docs.python.org/3/library/fileinput.html sometimes

echo 'one line' | python3 test.py - 
Fire trace:
1. Initial component
2. ('The function received no value for the required argument:', 'file_name')

should use std in instead file for input or output

dbieber commented 7 years ago

Supporting piping is high on the requested features list. We don't have a final design in place yet for what the syntax will be, so I'm open to suggestions if you have ideas.

Some of the questions we have to answer:

dbieber commented 7 years ago

Oh! I misunderstood your request. You can use - as a parameter as long as you change the separator to something else.

e.g. "echo 'one line' | python3 test.py - -- --separator=X" should do the trick. We don't have a supported way of changing the default separator at the moment.

ibeex commented 7 years ago

I was thinking maybe something like in http://click.pocoo.org/5/arguments/#file-arguments regarding pipe input.