shell

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2022 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package shell is sqly-shell. shell control user input (it's SQL query or helper command) and request the usecase layer to process it.

Index

Constants

This section is empty.

Variables

View Source
var (
	// Version is sqly command version. Version value is assigned by LDFLAGS.
	Version string
	// Stdout is new instance of Writer which handles escape sequence for stdout.
	Stdout = colorable.NewColorableStdout()
	// Stderr is new instance of Writer which handles escape sequence for stderr.
	Stderr = colorable.NewColorableStderr()
)
View Source
var (
	// ErrExitSqly is not error. developer must not print this error.
	ErrExitSqly = errors.New("this is not error. however, user want to exit sqly command")
)

Functions

This section is empty.

Types

type CommandList added in v0.0.2

type CommandList map[string]command

CommandList is sqly helper command list. key is command name, value is command function pointer and command description.

func NewCommands added in v0.0.2

func NewCommands() CommandList

NewCommands return *CommandList that set sqly helper commands.

type History added in v0.0.2

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

History is user input history manager.

func NewHistory added in v0.0.2

func NewHistory() *History

NewHistory return *History.

type Interactive added in v0.0.2

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

Interactive is user interface that provide command prompt.

func NewInteractive added in v0.0.2

func NewInteractive(h *History) *Interactive

NewInteractive return *Interactive

type Shell

type Shell struct {
	Ctx context.Context

	CsvInteractor     *usecase.CSVInteractor
	Sqlite3Interactor *usecase.SQLite3Interactor
	// contains filtered or unexported fields
}

Shell is main class of the sqly command. Shell is the interface to the user and requests processing from the usecase layer.

func NewShell

func NewShell(arg *config.Arg, cmds CommandList, interactive *Interactive,
	csv *usecase.CSVInteractor, sqlite3 *usecase.SQLite3Interactor) *Shell

NewShell return *Shell.

func (*Shell) Run

func (s *Shell) Run() error

Run start sqly shell. After successful initialization, start the interactive shell.

Jump to

Keyboard shortcuts

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