mirror of
https://github.com/turbot/steampipe.git
synced 2026-05-11 00:02:37 -04: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
71 lines
2.0 KiB
Go
71 lines
2.0 KiB
Go
package metaquery
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
typeHelpers "github.com/turbot/go-kit/types"
|
|
"github.com/turbot/steampipe/pkg/cmdconfig"
|
|
"github.com/turbot/steampipe/pkg/constants"
|
|
)
|
|
|
|
type handler func(ctx context.Context, input *HandlerInput) error
|
|
|
|
// Handle handles a metaquery execution from the interactive client
|
|
func Handle(ctx context.Context, input *HandlerInput) error {
|
|
cmd, _ := getCmdAndArgs(input.Query)
|
|
metaQueryObj, found := metaQueryDefinitions[cmd]
|
|
if !found {
|
|
return fmt.Errorf("not sure how to handle '%s'", cmd)
|
|
}
|
|
handlerFunction := metaQueryObj.handler
|
|
return handlerFunction(ctx, input)
|
|
}
|
|
|
|
// .header
|
|
// set the ArgHeader viper key with the boolean value evaluated from arg[0]
|
|
func setHeader(_ context.Context, input *HandlerInput) error {
|
|
cmdconfig.Viper().Set(constants.ArgHeader, typeHelpers.StringToBool(input.args()[0]))
|
|
return nil
|
|
}
|
|
|
|
// .multi
|
|
// set the ArgMulti viper key with the boolean value evaluated from arg[0]
|
|
func setMultiLine(_ context.Context, input *HandlerInput) error {
|
|
cmdconfig.Viper().Set(constants.ArgMultiLine, typeHelpers.StringToBool(input.args()[0]))
|
|
return nil
|
|
}
|
|
|
|
// .timing
|
|
// set the ArgHeader viper key with the boolean value evaluated from arg[0]
|
|
func setTiming(_ context.Context, input *HandlerInput) error {
|
|
cmdconfig.Viper().Set(constants.ArgTiming, typeHelpers.StringToBool(input.args()[0]))
|
|
return nil
|
|
}
|
|
|
|
// .separator and .output
|
|
// set the value of `viperKey` in `viper` with the value from `args[0]`
|
|
func setViperConfigFromArg(viperKey string) handler {
|
|
return func(_ context.Context, input *HandlerInput) error {
|
|
cmdconfig.Viper().Set(viperKey, input.args()[0])
|
|
return nil
|
|
}
|
|
}
|
|
|
|
// .exit
|
|
func doExit(_ context.Context, input *HandlerInput) error {
|
|
input.ClosePrompt()
|
|
return nil
|
|
}
|
|
|
|
// .clear
|
|
func clearScreen(_ context.Context, input *HandlerInput) error {
|
|
input.Prompt.ClearScreen()
|
|
return nil
|
|
}
|
|
|
|
// .autocomplete
|
|
func setAutoComplete(_ context.Context, input *HandlerInput) error {
|
|
cmdconfig.Viper().Set(constants.ArgAutoComplete, typeHelpers.StringToBool(input.args()[0]))
|
|
return nil
|
|
}
|