Influxdb: CLI to support multi-line queries

Created on 30 Sep 2015  路  9Comments  路  Source: influxdata/influxdb

In quite a few cases, the query can be longer than one line can fit, so we have to move cursors back and forth to check the whole query.

Possible ways:

  1. Use a liner which wraps line automatically.
  2. Parse query in CLI and show prompt accordingly, something like python interpreter.
  3. check trailing backslash, and join them to form a single query, like bash.

1 would be simplest given such library exists (or extend https://github.com/peterh/liner to support it), 3 is also acceptable and trivial to implement.

How do you guys think?

difficultmedium

Most helpful comment

Apologies for commenting on an old issue but I'm having trouble figuring out if/ how this works. I'm using v0.11 and I'm seeing the following behavior in the interactive CLI:

> CREATE CONTINUOUS QUERY cq_hourly_readings ON myDB  BEGIN
ERR: error parsing query: found EOF, expected SELECT at line 1, char 67
> CREATE CONTINUOUS QUERY cq_hourly_readings ON myDB  BEGIN \
ERR: error parsing query: found \, expected SELECT at line 1, char 67

I also can't find any mention of this issue in the CHANGELOG. Has it been released?

All 9 comments

This would definitely be useful -- thanks @fffw . I think 1 and 3 are most feasible. I'd like to see 1 in action.

liner is inspired by linenoise, and linenoise supports multiline mode.

I think it's appropriate to patch liner to support it, and I'll give it a try if you guys like this idea.

Thanks @flisky -- if you patch liner, will you need to wait for that patch to be merged before we can use it?

Yes, I think so. Upstream merge is great, and liner seems to be active maintained.

OK, since we already import the package I think it's a valid approach.

Awesome :clap:

Apologies for commenting on an old issue but I'm having trouble figuring out if/ how this works. I'm using v0.11 and I'm seeing the following behavior in the interactive CLI:

> CREATE CONTINUOUS QUERY cq_hourly_readings ON myDB  BEGIN
ERR: error parsing query: found EOF, expected SELECT at line 1, char 67
> CREATE CONTINUOUS QUERY cq_hourly_readings ON myDB  BEGIN \
ERR: error parsing query: found \, expected SELECT at line 1, char 67

I also can't find any mention of this issue in the CHANGELOG. Has it been released?

This issue added support for line wrapping (option 1 above). Multiline queries with trailing backslashes are not currently supported. Please open a new issue with a feature request if you'd like it added.

Note that new lines can be be included in queries, without backslashes, when directly interacting with the HTTP /query endpoint.

Was this page helpful?
0 / 5 - 0 ratings