completer

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 2024 License: MIT Imports: 11 Imported by: 0

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

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

CompleteFromList where items starts with text, ignoring case

func CompleteFromListCase

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

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

TailMatches when last words match all patterns

Types

type CompleteFunc

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

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