Add REPL autocompletion & go-prompt (#392)

* add v1-compatible query path and refactor other paths to de-duplicate "/query"

* add initial influxQL repl

* add ping endpoint to schema

* improve prompt UX, implement some commands

* fix json column type in schema and improve completion

* feat: add table formatter and move to forked go-prompt

* improve formatting and add table pagination

* implement more REPL commands, including insert and history

* implement "INSERT INTO"

* move repl command to "v1 repl"

* refactor and improve documentation

* clean up v1_repl cmd

* update to latest openapi, use some openapi paths instead of overrides

* remove additional files that were moved to openapi

* compute historyFilePath at REPL start

* clean up REPL use command logic flow

* clean up comments for TODOs now in issues

* move gopher (chonky boi)

* remove autocompletion for separate PR

* run go mod tidy

* add back autocompletion & go-prompt

* add rfc3339 precision option

* allow left and right column scrolling to display whole table

* add error to JSON query response

* add tags and partial to JSON response series schema

* fix csv formatting and add column formatting

* remove table format for separate PR

* fix getDatabases

* move from write to legacy write endpoint for INSERT

* remove history vestiges

* allow multiple spaces in INSERT commands

* add precision comment

* remove auth for separate PR

* separate parseInsert and add unit test

* add additional test case and improve error messages

* fix missing errors import

* fix format suggestion

* re-add history implementation with history limit

* build: upgrade to Go 1.18.3 (#395)

* feat: add back the InfluxQL REPL (#386)

* add v1-compatible query path and refactor other paths to de-duplicate "/query"

* add initial influxQL repl

* add ping endpoint to schema

* improve prompt UX, implement some commands

* fix json column type in schema and improve completion

* feat: add table formatter and move to forked go-prompt

* improve formatting and add table pagination

* implement more REPL commands, including insert and history

* implement "INSERT INTO"

* move repl command to "v1 repl"

* refactor and improve documentation

* clean up v1_repl cmd

* update to latest openapi, use some openapi paths instead of overrides

* remove additional files that were moved to openapi

* compute historyFilePath at REPL start

* clean up REPL use command logic flow

* clean up comments for TODOs now in issues

* move gopher (chonky boi)

* remove autocompletion for separate PR

* run go mod tidy

* add rfc3339 precision option

* allow left and right column scrolling to display whole table

* add error to JSON query response

* add tags and partial to JSON response series schema

* fix csv formatting and add column formatting

* remove table format for separate PR

* fix getDatabases

* move from write to legacy write endpoint for INSERT

* remove history vestiges

* allow multiple spaces in INSERT commands

* add precision comment

* remove auth for separate PR

* separate parseInsert and add unit test

* add additional test case and improve error messages

* fix missing errors import

* print rfc3339 precision

* add rfc3339 to help output

* run tidy

* restructure autocomplete and handle review items

* improve autocompletion with leftover handling

* improve comments and add autocomplete for DELETE & DROP MEASUREMENT

* rename repl to shell

* remove unsupported CREATE & DROP autocompletions

* additional refactor for autocompletion

Co-authored-by: Dane Strandboge <dstrandboge@influxdata.com>
This commit is contained in:
Andrew Lee
2022-06-14 15:18:27 -06:00
committed by GitHub
parent 0c17ebd621
commit c695e601a5
9 changed files with 324 additions and 32 deletions

View File

@ -13,7 +13,7 @@ func newV1SubCommand() cli.Command {
Subcommands: []cli.Command{
newV1DBRPCmd(),
newV1AuthCommand(),
newV1ReplCmd(),
newV1ShellCmd(),
},
}
}

View File

@ -4,7 +4,7 @@ import (
"github.com/fatih/color"
"github.com/influxdata/influx-cli/v2/api"
"github.com/influxdata/influx-cli/v2/clients"
repl "github.com/influxdata/influx-cli/v2/clients/v1_repl"
shell "github.com/influxdata/influx-cli/v2/clients/v1_shell"
"github.com/influxdata/influx-cli/v2/pkg/cli/middleware"
"github.com/urfave/cli"
)
@ -14,13 +14,13 @@ type Client struct {
api.LegacyQueryApi
}
func newV1ReplCmd() cli.Command {
func newV1ShellCmd() cli.Command {
var orgParams clients.OrgParams
persistentQueryParams := repl.DefaultPersistentQueryParams()
persistentQueryParams := shell.DefaultPersistentQueryParams()
return cli.Command{
Name: "repl",
Usage: "Start an InfluxQL REPL",
Description: "Start an InfluxQL REPL",
Name: "shell",
Usage: "Start an InfluxQL shell",
Description: "Start an InfluxQL shell",
Before: middleware.WithBeforeFns(withCli(), withApi(true)),
Flags: append(commonFlagsNoPrint(), getOrgFlags(&orgParams)...),
Action: func(ctx *cli.Context) error {
@ -28,7 +28,7 @@ func newV1ReplCmd() cli.Command {
return err
}
api := getAPI(ctx)
c := repl.Client{
c := shell.Client{
CLI: getCLI(ctx),
PersistentQueryParams: persistentQueryParams,
PingApi: api.PingApi,