tursodatabase / turso-cli

Command line interface to Turso.
https://turso.tech
MIT License
224 stars 37 forks source link

Add an option to run a SQL file with `turso db shell` #365

Open penberg opened 1 year ago

penberg commented 1 year ago

You can currently do cat <file> | turso db shell <name> but let's add an explicit command line option.

CodingDoug commented 1 year ago

It's also possible to do this, which is very reasonable: turso db shell $DB < file.sql

The important thing that's missing in either case is detection that input is not coming from a TTY. If we detect that, then the shell should not output its welcome message nor cook the terminal inputs and outputs. That will make it run a lot faster for large inputs.

The question is then: what is the output if processing entirely non-interactively?

psarna commented 1 year ago

The important thing that's missing in either case is detection that input is not coming from a TTY. If we detect that, then the shell should not output its welcome message nor cook the terminal inputs and outputs. That will make it run a lot faster for large inputs.

Or maybe just implement a --silent/-s flag, curl style?

CodingDoug commented 1 year ago

The important thing that's missing in either case is detection that input is not coming from a TTY. If we detect that, then the shell should not output its welcome message nor cook the terminal inputs and outputs. That will make it run a lot faster for large inputs.

Or maybe just implement a --silent/-s flag, curl style?

It looks pretty easy to do without an explicit flag: https://stackoverflow.com/questions/43947363/detect-if-a-command-is-piped-or-not

I feel like this sort of detection is pretty normal for unix-y sort of command line tools.