clippan

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2021 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Commands []*Command
View Source
var DatabaseDoesNotExist = errors.New("Database does not exist")
View Source
var DatabaseExists = errors.New("Database already exists")
View Source
var DocumentNotFoundError = errors.New("Document not found")
View Source
var NoDatabaseError = errors.New("Not connected to a database")
View Source
var UsageError = errors.New("Incorrect Usage")

Functions

func AllDocs

func AllDocs(c *Clippan, args []string) error

AllDocs simply returns what _all_docs returns, Will eventually support pagination and simple start/end filtering

func CreateDB

func CreateDB(c *Clippan, args []string) error

func Databases

func Databases(c *Clippan, args []string) error

func DeleteDB

func DeleteDB(c *Clippan, args []string) error

func Edit

func Edit(c *Clippan, args []string) error

func EditPut

func EditPut(c *Clippan, args []string, onlyEdit bool) error

Put craetes a new document

func Exit

func Exit(c *Clippan, args []string) error

func Get

func Get(c *Clippan, args []string) error

Get returns a single document

func GetDocRaw

func GetDocRaw(c *Clippan, id string) ([]byte, map[string]interface{}, error)

GetDocRaw gets a document as raw bytes. It returns DocumentNotFoundError if not found, or any other error encountered

func Help

func Help(c *Clippan, args []string) error

func MatchDatabases

func MatchDatabases(c *Clippan, patterns ...string) ([]string, []string, error)

func MustMarshal

func MustMarshal(v interface{}) []byte

func MustUnmarshal

func MustUnmarshal(raw []byte, target interface{})

func Put

func Put(c *Clippan, args []string) error

func Query

func Query(c *Clippan, args []string) error

Query might be aliased / shortcut to Map(view), Reduce?

func UseDB

func UseDB(c *Clippan, args []string) error

func ValidateJSON

func ValidateJSON(data []byte) error

Types

type Clippan

type Clippan struct {

	// DI
	Printer Printer
	Editor  Editor
	Prompt  Prompter
	// contains filtered or unexported fields
}

func NewClippan

func NewClippan(dsn string, enableWrite, debug bool) *Clippan

func (*Clippan) Connect

func (c *Clippan) Connect() error

func (*Clippan) Debug

func (c *Clippan) Debug(format string, args ...interface{})

func (*Clippan) Error

func (c *Clippan) Error(format string, args ...interface{})

func (*Clippan) Executer

func (c *Clippan) Executer(s string)

func (*Clippan) JSON

func (c *Clippan) JSON(raw []byte)

func (*Clippan) Print

func (c *Clippan) Print(format string, args ...interface{})

func (*Clippan) Run

func (c *Clippan) Run(cmds string)

Run starts clippan, connecting to the provided dsn (may be empty, may contain database). The optional (can be empty) cmd is a set of commands to parse

func (*Clippan) RunCmds

func (c *Clippan) RunCmds(cmds string)

func (*Clippan) UseDB

func (c *Clippan) UseDB(db string) bool

type Command

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

type Editor

type Editor interface {
	Edit([]byte) ([]byte, error)
}

type Flag

type Flag uint8
const (
	None           Flag = 0
	NeedConnection Flag = iota << 1
	NeedDatabase
)

type Printer

type Printer interface {
	Error(string, ...interface{})
	Debug(string, ...interface{})
	Print(string, ...interface{})
	JSON([]byte)
}

type Prompt

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

func NewPrompt

func NewPrompt() *Prompt

func (*Prompt) GetInput

func (p *Prompt) GetInput(executer func(string))

GetInput gets input from the user and calls the provided callback

func (*Prompt) Input

func (p *Prompt) Input(s string) string

Request simple input

func (*Prompt) SetPrompt

func (p *Prompt) SetPrompt(s string)

type Prompter

type Prompter interface {
	GetInput(func(string))
	SetPrompt(string)
	Input(string) string
}

type QueryResult

type QueryResult struct {
	ID    string      `json:"id"`
	Key   interface{} `json:"key"`
	Value interface{} `json:"value"`
}

type RealEditor

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

Actually edit a file using a real editor and a tempfile

func NewRealEditor

func NewRealEditor(editor string) *RealEditor

func (*RealEditor) Edit

func (r *RealEditor) Edit(content []byte) ([]byte, error)

type TextPrinter

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

func (*TextPrinter) Debug

func (p *TextPrinter) Debug(format string, args ...interface{})

func (*TextPrinter) Error

func (p *TextPrinter) Error(format string, args ...interface{})

func (*TextPrinter) JSON

func (p *TextPrinter) JSON(raw []byte)

func (*TextPrinter) Print

func (p *TextPrinter) Print(format string, args ...interface{})

Jump to

Keyboard shortcuts

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