Added command history (#45)
* Added command line history to the command, query and filter prompts. * Added query planning debugging to the log. * Fixed bug in query expression which was not treating true and false as boolean literals. * Fixed a bug in the query planning logic which was incorrectly determine that an expression of the form sort_key ^= "string", with no partition key, could be executed as a query instead of a scan.
This commit is contained in:
parent
700a1a2253
commit
54a120342e
26 changed files with 335 additions and 34 deletions
|
|
@ -3,6 +3,7 @@ package commandctrl
|
|||
import (
|
||||
"bufio"
|
||||
"bytes"
|
||||
"context"
|
||||
tea "github.com/charmbracelet/bubbletea"
|
||||
"github.com/pkg/errors"
|
||||
"log"
|
||||
|
|
@ -14,13 +15,17 @@ import (
|
|||
"github.com/lmika/shellwords"
|
||||
)
|
||||
|
||||
const commandsCategory = "commands"
|
||||
|
||||
type CommandController struct {
|
||||
historyProvider IterProvider
|
||||
commandList *CommandList
|
||||
lookupExtensions []CommandLookupExtension
|
||||
}
|
||||
|
||||
func NewCommandController() *CommandController {
|
||||
func NewCommandController(historyProvider IterProvider) *CommandController {
|
||||
return &CommandController{
|
||||
historyProvider: historyProvider,
|
||||
commandList: nil,
|
||||
lookupExtensions: nil,
|
||||
}
|
||||
|
|
@ -37,7 +42,8 @@ func (c *CommandController) AddCommandLookupExtension(ext CommandLookupExtension
|
|||
|
||||
func (c *CommandController) Prompt() tea.Msg {
|
||||
return events.PromptForInputMsg{
|
||||
Prompt: ":",
|
||||
Prompt: ":",
|
||||
History: c.historyProvider.Iter(context.Background(), commandsCategory),
|
||||
OnDone: func(value string) tea.Msg {
|
||||
return c.Execute(value)
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue