snippet

package
v0.0.0-...-460bf00 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2021 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	COMMAND  = "Commands"
	CODE     = "Code snippets"
	BOOKMARK = "Bookmarks"
	SNIP     = "SNIP"
)

Variables

View Source
var ErrEditCanceled = errors.New("edit canceled")
View Source
var ErrExecCanceled = errors.New("execution canceled")
View Source
var ErrNotExecutable = errors.New("not executable")

Functions

This section is empty.

Types

type Bookmark

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

func NewBookmark

func NewBookmark(url, description string, tags string) Bookmark

func (*Bookmark) Data

func (b *Bookmark) Data() *SnippetData

func (*Bookmark) Edit

func (b *Bookmark) Edit() error

func (*Bookmark) Execute

func (b *Bookmark) Execute() error

func (*Bookmark) String

func (b *Bookmark) String() string

func (*Bookmark) Type

func (b *Bookmark) Type() SnippetType

type Code

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

func NewCode

func NewCode(content, description string, tags string, language string) Code

func (*Code) Data

func (c *Code) Data() *SnippetData

func (*Code) Edit

func (c *Code) Edit() error

func (*Code) Execute

func (c *Code) Execute() error

func (*Code) String

func (c *Code) String() string

func (*Code) Type

func (c *Code) Type() SnippetType

type Command

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

func NewCommand

func NewCommand(content, description string, tags string) Command

func (*Command) Data

func (cmd *Command) Data() *SnippetData

func (*Command) Edit

func (c *Command) Edit() error

func (*Command) Execute

func (c *Command) Execute() error

func (*Command) String

func (c *Command) String() string

func (*Command) Type

func (cmd *Command) Type() SnippetType

type Filters

type Filters struct {
	Type     SnippetType
	Language string
	Tags     string
}

Filters are used to filter the snippets list

func (Filters) String

func (f Filters) String() string

type Repository

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

Repository is the main accessor for snippets in the DB

func NewRepository

func NewRepository() *Repository

NewRepository returns a new snippet resository

func (*Repository) Add

func (r *Repository) Add(s Snippet)

Add a new snippet to the database

func (*Repository) Del

func (r *Repository) Del(id int)

Del removes a snippet with the given ID

func (*Repository) FindWithFilters

func (r *Repository) FindWithFilters(filters Filters) []Snippet

FindWithFilters returns snippets that match the given filters

func (*Repository) Get

func (r *Repository) Get(id int) Snippet

Get returns a snippet with the given ID

func (*Repository) Save

func (r *Repository) Save(s Snippet)

Save an existing snippet to the database

type Snippet

type Snippet interface {
	Type() SnippetType
	Data() *SnippetData
	Execute() error
	Edit() error
	String() string
}

func New

func New(sd SnippetData) Snippet

type SnippetData

type SnippetData struct {
	ID          int64
	Content     string
	Description string
	Tags        string
	Type        SnippetType
	Language    string
}

SnippetData contains the data for one snippet

type SnippetType

type SnippetType string

Jump to

Keyboard shortcuts

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