xo / usql

Universal command-line interface for SQL databases
MIT License
8.94k stars 351 forks source link

Is there a way to see console prompts when using -o? #270

Closed shueybubbles closed 3 years ago

shueybubbles commented 3 years ago

xo/usql/rline looks like a good basis for my own app that has both interactive and non-interactive modes but it seems there's no way to give it separate output pipes for prompts and non-prompts, and prompts just seem to do nothing when the output file name is non-empty.

One result is that ussql itself doesn't show any prompts in the console when using -o, which was unexpected behavior to me. I was expecting behavior like sqlcmd

Sample console output from sqlcmd:

I:\>"C:\Program Files\Microsoft SQL Server\110\Tools\Binn\SQLCMD.EXE"  -o c:\temp\myfile.txt
1> select 1
2> go
1> select 100
2> go
1> quit

I:\>type c:\temp\myfile.txt

-----------
          1

(1 rows affected)

-----------
        100

(1 rows affected)
kenshaw commented 3 years ago

I would not suggest, nor advise on using xo/usql/rline in your own project, as its mostly a wrapper around the readline package that usql uses.

Prompts get disabled when not in interactive mode in usql, which is the same behavior (as far as I'm aware) of psql having. usql is designed to behave/look/feel the same as psql and not as SQL Server's sqlcmd.exe.