FoundationDB/sql-layer-client-tools — pull request #26 by nathanlws (2013-12-19 00:39:27+00:00)
Title: Basic CLI client

Though quite functional.

It's replaced my psql usage for the last week and change. The only thing I miss, at the moment, is `\timing`. Perhaps if we all use it as such, we'll get the relevant accumulation of features to be confident in shipping it.

And overview of external and internal help:
```
$ ./bin/fdbsqlcli --help
Usage: fdbsqlcli [options] [schema]
Options:
-f, --file execute commands from file and then exit
--help
Default: false
-h, --host name of server host
Default: localhost
-w, --password server user password
Default:
-p, --port SQL Layer port
Default: 15432
-s, --schema server user name
Default: nathanlws
-u, --user server user name
Default: nathanlws

$ ./bin/fdbsqlcli
fdbsql (driver 1.9, layer 1.9.3)
nathanlws=> \?
\c [SCHEMA] [USER] [HOST] [PORT] change connection information
\conninfo display connection information
\dt[S][+] [SCHEMA] NAME] describe tables
\dv[S][+] [SCHEMA] NAME] describe views
\l[S] [[SCHEMA] NAME] list tables, views and sequences
\li[S][+] [[[SCHEMA] TABLE] NAME] list indexes
\lq[S][+] [[SCHEMA] NAME] list sequences
\ls[S][+] [NAME] list schemata
\lt[S][+] [[SCHEMA] NAME] list tables
\lv[S][+] [[SCHEMA] NAME] list views
\? display this help
\q quit
```

Random bits of insight:
- jLine2 is mostly up to the task and seems to work as described on OS X, Linux and Windows (7).
- Including line editing, search and persistent history
- Only major annoyance is lack of multi-line history support. I don't think it is systemic, but would be a non-trivial PR to fix.
- In addition to command line arguments, FDBSQL_{HOST,PORT,..} env vars are looked for.
- The backslash commands are (clearly) inspired by psql but I took some liberties in the hopes of making the mnemonics easier
- Custom queries are used instead of JDBC metadata. Reasoning: the metadata results contain lots of noise (e.g. catalog) and don't custom useful bits (e.g. storage name).

Some of the bits (e.g. arguments, environment variables) should probably be factored out and shared among all programs for consistency. There are, of course, lots of nice to haves: more backslash, extended output format, etc but I think this is a pretty functional start.