mirror of
https://github.com/turbot/steampipe.git
synced 2026-02-17 19:00:12 -05:00
- Execute RefreshConnections asyncronously - Add connection_state table to indicate the loading state of connections - Optimise RefreshConnections by cloning connection schemas - Add locking to ensure only a single instance of RefreshConnections runs - Start executing queries without waiting for connections to load, add smart error handling to wait for required connection - Optimise autocomplete for high connection count - Autocomplete and inspect data available before all conections are refreshed - Update file watcher to respond to CHMOD, so thaat it pickes up deletion of file contents Closes #3394 Closes #3267
46 lines
1.2 KiB
Go
46 lines
1.2 KiB
Go
package metaquery
|
|
|
|
import (
|
|
"strings"
|
|
|
|
"github.com/c-bata/go-prompt"
|
|
)
|
|
|
|
// CompleterInput is a struct defining input data for the metaquery completer
|
|
type CompleterInput struct {
|
|
Query string
|
|
TableSuggestions []prompt.Suggest
|
|
}
|
|
|
|
type completer func(input *CompleterInput) []prompt.Suggest
|
|
|
|
// Complete returns completions for metaqueries.
|
|
func Complete(input *CompleterInput) []prompt.Suggest {
|
|
input.Query = strings.TrimSuffix(input.Query, ";")
|
|
cmd, _ := getCmdAndArgs(input.Query)
|
|
|
|
metaQueryObj, found := metaQueryDefinitions[cmd]
|
|
if !found {
|
|
return []prompt.Suggest{}
|
|
}
|
|
if metaQueryObj.completer == nil {
|
|
return []prompt.Suggest{}
|
|
}
|
|
return metaQueryObj.completer(input)
|
|
}
|
|
|
|
func completerFromArgsOf(cmd string) completer {
|
|
return func(input *CompleterInput) []prompt.Suggest {
|
|
metaQueryDefinition := metaQueryDefinitions[cmd]
|
|
suggestions := make([]prompt.Suggest, len(metaQueryDefinition.args))
|
|
for idx, arg := range metaQueryDefinition.args {
|
|
suggestions[idx] = prompt.Suggest{Text: arg.value, Description: arg.description, Output: arg.value}
|
|
}
|
|
return suggestions
|
|
}
|
|
}
|
|
|
|
func inspectCompleter(input *CompleterInput) []prompt.Suggest {
|
|
return input.TableSuggestions
|
|
}
|