gluesql icon indicating copy to clipboard operation
gluesql copied to clipboard

Support `.spool FilePath` command in CLI

Open devgony opened this issue 3 years ago • 1 comments

To resolve #747

Goal

Spool is the easiest way to export data.

gluesql> .spool query.log
gluesql> VALUES (1), (2);
╭─────────╮
│ column1 │
╞═════════╡
│ 1       │
│ 2       │
╰─────────╯

gluesql> .spool off
gluesql> .quit
$> cat query.log
╭─────────╮
│ column1 │
╞═════════╡
│ 1       │
│ 2       │
╰─────────╯

Todo

  • [x] Add Command::SpoolOn, CommandError::LackOfFile
  • [x] Add Command::SpoolOff
  • [x] if Some(spool_file), write to spool_file whenver print payload

Q

  • Should we test the contents of created spool_file ?

In Next PR

Support granular options

  • set header on | off
  • set tabular on | off
  • set echo on | off (show executed query or not)

devgony avatar Aug 12 '22 08:08 devgony

Pull Request Test Coverage Report for Build 2845690810

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.05%) to 97.896%

Totals Coverage Status
Change from base Build 2833363350: 0.05%
Covered Lines: 29550
Relevant Lines: 30185

💛 - Coveralls

coveralls avatar Aug 12 '22 08:08 coveralls

Should we test the contents of created spool_file ?

It would be good to have one, but currently... it is not easy to make test based on rustyline. We may need to add test using internal function.

panarch avatar Aug 14 '22 15:08 panarch