Feat/basic auto completion - #40
Conversation
Signed-off-by: Balaji J <j.balaji2468@gmail.com>
Signed-off-by: Balaji J <j.balaji2468@gmail.com>
Signed-off-by: Balaji J <j.balaji2468@gmail.com>
There was a problem hiding this comment.
Pull request overview
Adds basic SQL keyword autocompletion to the interactive prompt by embedding a PostgreSQL keyword list and wiring it into the prompt reader during CLI initialization.
Changes:
- Replace the previous embedded JSON literals blob with an embedded plain-text PostgreSQL keyword list.
- Load keywords at CLI startup and configure the prompt’s autocompleter with those suggestions.
- Rename the app constructor (
NewPgxCLI→New) and bumpgo-prompterto a newer pseudo-version to support the new completion API.
Reviewed changes
Copilot reviewed 9 out of 10 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| internal/parser/pgliterals.json | Removes the old embedded JSON literal dataset (keywords/functions/datatypes/reserved). |
| internal/parser/pgliterals.go | Removes JSON embedding + parsing helpers for PG literals. |
| internal/parser/pg_kw.txt | Adds embedded plain-text PostgreSQL keyword list used for completion. |
| internal/parser/pg_kw.go | Adds loader that parses the embedded keyword file into a suggestion slice. |
| internal/parser/pg_kw_test.go | Adds a unit test asserting keyword list loads and contains common commands. |
| internal/cli/root.go | Loads PG keywords during startup and injects them into the app as autocompletion suggestions. |
| internal/app/reader.go | Extends the Reader interface and configures go-prompter autocompletion from keyword suggestions. |
| internal/app/app.go | Renames constructor to New and adds SetAutocompleter passthrough to the reader. |
| go.mod | Updates github.com/jedib0t/go-prompter version to support new completion methods. |
| go.sum | Updates checksums for the new go-prompter version. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| func (r *PgxReader) SetAutocompleter(keywords []string) { | ||
| suggestions := make([]prompt.Suggestion, len(keywords)) | ||
| for i, kw := range keywords { | ||
| suggestions[i] = prompt.Suggestion{Value: kw} | ||
| } | ||
| r.prompt.SetAutoCompleterContextual(prompt.AutoCompleteSimple(suggestions, true)) | ||
| } |
There was a problem hiding this comment.
SetAutocompleter introduces new interactive behavior, but there’s no unit test verifying that the prompter’s autocompleter is actually configured (e.g., that SetAutoCompleterContextual is invoked with a non-nil completer and the expected suggestion values). Consider adding a small test using a stub/mock prompt.Prompter to prevent regressions when upgrading go-prompter or refactoring the reader.
No description provided.