handler

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2017 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrDriverNotAvailable is the driver not available error.
	ErrDriverNotAvailable = errors.New("driver not available")

	// ErrNotConnected is the not connected error.
	ErrNotConnected = errors.New("not connected")

	// ErrNoSuchFileOrDirectory is the no such file or directory error.
	ErrNoSuchFileOrDirectory = errors.New("no such file or directory")

	// ErrCannotIncludeDirectories is the cannot include directories error.
	ErrCannotIncludeDirectories = errors.New("cannot include directories")

	// ErrNoEditorDefined is the no editor defined error.
	ErrNoEditorDefined = errors.New("no editor defined")
)

Functions

func SetAvailableDrivers

func SetAvailableDrivers(m map[string]string)

SetAvailableDrivers sets the known available drivers.

Types

type Error

type Error struct {
	Driver string
	Err    error
}

Error is a wrapper to standardize errors.

func (*Error) Error

func (e *Error) Error() string

Error satisfies the error interface.

type Handler

type Handler struct {
	// contains filtered or unexported fields
}

Handler is a input process handler.

func New

func New(histfile, homedir, wd string, interactive, cygwin bool) (*Handler, error)

New creates a new input handler.

func (*Handler) Close

func (h *Handler) Close() error

Close closes the database connection if it is open.

func (*Handler) DisplayHelp

func (h *Handler) DisplayHelp(w io.Writer)

DisplayHelp displays the help message.

func (*Handler) Execute

func (h *Handler) Execute(w io.Writer, sqlstr string, auto, forceExec bool) error

Execute executes a sql query against the connected database.

func (*Handler) ForceInteractive

func (h *Handler) ForceInteractive(interactive bool)

ForceInteractive forces the interactive mode.

func (*Handler) HistoryFile

func (h *Handler) HistoryFile() string

HistoryFile returns the history file name for the handler.

func (*Handler) IncludeFile

func (h *Handler) IncludeFile(path string, relative bool) error

IncludeFile includes the specified path.

func (*Handler) LaunchEditor

func (h *Handler) LaunchEditor(path, line, stmt string) ([]rune, error)

LaunchEditor launches an editor using the current query buffer.

func (*Handler) Open

func (h *Handler) Open(urlstr string) error

Open handles opening a specified database URL.

func (*Handler) Process

func (h *Handler) Process(stdin io.Reader, stdout, stderr io.Writer) error

Process reads line commands from stdin, writing output to stdout and stderr.

func (*Handler) Query

func (h *Handler) Query(w io.Writer, sqlstr string) error

Query executes a query against the database.

func (*Handler) Reset

func (h *Handler) Reset()

Reset resets the line parser state.

func (*Handler) RunCommands

func (h *Handler) RunCommands(cmds []string) error

RunCommands processes command line arguments.

func (*Handler) RunReadline

func (h *Handler) RunReadline(in, out string) error

RunReadline processes input.

func (*Handler) SetPrompt

func (h *Handler) SetPrompt(l *readline.Instance)

SetPrompt sets the prompt on a readline instance.

func (*Handler) WrapError

func (h *Handler) WrapError(err error) error

WrapError conditionally wraps an error if the error occurs while connected to a database.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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