Handle file, stream, or text input.

Also add a CLI test.