completer

package
v0.14.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 5, 2023 License: MIT Imports: 11 Imported by: 3

Documentation

Overview

completer package provides a generic SQL command line completer

Index

Constants

View Source
const (
	WORD_BREAKS = "\t\n$><=;|&{() "
)

Variables

View Source
var (
	IGNORE_CASE            = caseType(true)
	MATCH_CASE             = caseType(false)
	CommonSqlStartCommands = []string{
		"ABORT",
		"ALTER",
		"ANALYZE",
		"BEGIN",
		"CALL",
		"CHECKPOINT",
		"CLOSE",
		"CLUSTER",
		"COMMENT",
		"COMMIT",
		"COPY",
		"CREATE",
		"DEALLOCATE",
		"DECLARE",
		"DELETE FROM",
		"DESC",
		"DESCRIBE",
		"DISCARD",
		"DO",
		"DROP",
		"END",
		"EXEC",
		"EXECUTE",
		"EXPLAIN",
		"FETCH",
		"GRANT",
		"IMPORT",
		"INSERT",
		"LIST",
		"LISTEN",
		"LOAD",
		"LOCK",
		"MOVE",
		"NOTIFY",
		"PRAGMA",
		"PREPARE",
		"REASSIGN",
		"REFRESH MATERIALIZED VIEW",
		"REINDEX",
		"RELEASE",
		"RESET",
		"REVOKE",
		"ROLLBACK",
		"SAVEPOINT",
		"SECURITY LABEL",
		"SELECT",
		"SET",
		"SHOW",
		"START",
		"TABLE",
		"TRUNCATE",
		"UNLISTEN",
		"UPDATE",
		"VACUUM",
		"VALUES",
		"WITH",
	}
	CommonSqlCommands = []string{
		"AND",
		"CASE",
		"CROSS JOIN",
		"ELSE",
		"END",
		"FETCH",
		"FROM",
		"FULL OUTER JOIN",
		"GROUP BY",
		"HAVING",
		"IN",
		"INNER JOIN",
		"IS NOT NULL",
		"IS NULL",
		"JOIN",
		"LEFT JOIN",
		"LIMIT",
		"NOT",
		"ON",
		"OR",
		"ORDER BY",
		"THEN",
		"WHEN",
		"WHERE",
	}
)

Functions

func CompleteFromList added in v0.9.3

func CompleteFromList(text []rune, options ...string) [][]rune

CompleteFromList where items starts with text, ignoring case

func CompleteFromListCase added in v0.9.3

func CompleteFromListCase(ct caseType, text []rune, options ...string) [][]rune

CompleteFromList where items starts with text

func NewDefaultCompleter

func NewDefaultCompleter(opts ...Option) readline.AutoCompleter

func TailMatches added in v0.9.3

func TailMatches(ct caseType, words []string, patterns ...string) bool

TailMatches when last words match all patterns

Types

type CompleteFunc added in v0.9.3

type CompleteFunc func(previousWords []string, text []rune) [][]rune

CompleteFunc returns patterns completing current text, using previous words as context

type Option

type Option func(*completer)

Option to configure the reader

func WithBeforeComplete added in v0.9.3

func WithBeforeComplete(f CompleteFunc) Option

WithBeforeComplete option

func WithConnStrings

func WithConnStrings(connStrings []string) Option

WithConnStrings option

func WithDB

func WithDB(db metadata.DB) Option

WithDB option

func WithLogger

func WithLogger(l logger) Option

WithLogger option

func WithReader

func WithReader(r metadata.Reader) Option

WithReader option

func WithSQLCommands

func WithSQLCommands(commands []string) Option

WithSQLCommands that can be any part of a query

func WithSQLStartCommands

func WithSQLStartCommands(commands []string) Option

WithSQLStartCommands that can begin a query

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL