multiprocessio / dsq

Commandline tool for running SQL queries against JSON, CSV, Excel, Parquet, and more.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Terminate output with newline?

vegarsti opened this issue · comments

What a cool and great tool! Not sure about you, but I always like command-line tools to add a final newline at the end. Maybe just because my terminal complains when it isn't the case: When I run this, I get a % sign at the end.

$ dsq imdb.csv 'select title from {}'
[{"Title":"Shawshank Redemption"}
,
{"Title":"The Godfather"}
,
{"Title":"The Godfather: Part II"}
,
{"Title":"The Dark Knight"}
,
{"Title":"12 Angry Men"}
]%
$

I looked around in the code but wasn't immediately sure where to suggest adding this, though.

Yeah this is annoying! At the moment I pipe the result of dsq through jq when I want pretty formatting. But I suppose I could add a flag for pretty (or in pretty) formatting to dsq itself.

You could e.g. add

fmt.Println()

at the end of main.go, after this:

dsq/main.go

Lines 270 to 273 in dedd036

_, err = io.Copy(os.Stdout, fd)
if err != nil {
log.Fatal(err)
}

If you pipe the output from dsq into something else I don't think this would mess that up

If you'd like, make a PR that does so! You may need to fix the one test in ./scripts/test.sh that tests literal result comparison and you'd just need to add a newline to the expected string.