psql --csv -c 'TABLE foo' > foo.csv
With a -c to introduce the command.
This seems pretty specialized. If we're adding something new, how about
psql --format=csv -o foo.csv -c 'TABLE foo'
Or we could stick with:
psql -P format=csv -o foo.csv -c 'TABLE foo'
Currently "-P format=csv" uses the unaligned formating separators, i.e.
'|' is used. I was suggesting that a special long option could switch
several variables to some specific values, i.e.
Would be equivalent to something like:
-P format=csv -P fieldsep=, -P recordsep=\n (?) -P tuples_only=on ...
I.e. really generate some csv from the data in just one option, not many.
But this is obviously debatable.