Make input and output format independant.
Add missing getopts fields.
Implement format handling.
Fix writing to stdin.
Make json compatible RPC output (incomplete).