snipm

package
v0.2.25 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2024 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	SNIPPET_TBL = "snippets"
)

Functions

func FilterText

func FilterText(customLabel tui.CustomLabel, options []string, tag string) (commands []string, err error)

func GetSnipDb

func GetSnipDb(logger *zerolog.Logger) (*db.Storage, error)

Types

type ByCommand

type ByCommand []SnippetInfo

func (ByCommand) Len

func (a ByCommand) Len() int

func (ByCommand) Less

func (a ByCommand) Less(i, j int) bool

func (ByCommand) Swap

func (a ByCommand) Swap(i, j int)

type ByDescription

type ByDescription []SnippetInfo

func (ByDescription) Len

func (a ByDescription) Len() int

func (ByDescription) Less

func (a ByDescription) Less(i, j int) bool

func (ByDescription) Swap

func (a ByDescription) Swap(i, j int)

type ByOutput

type ByOutput []SnippetInfo

func (ByOutput) Len

func (a ByOutput) Len() int

func (ByOutput) Less

func (a ByOutput) Less(i, j int) bool

func (ByOutput) Swap

func (a ByOutput) Swap(i, j int)

type ByTimestamp

type ByTimestamp []SnippetInfo

func (ByTimestamp) Len

func (a ByTimestamp) Len() int

func (ByTimestamp) Less

func (a ByTimestamp) Less(i, j int) bool

func (ByTimestamp) Swap

func (a ByTimestamp) Swap(i, j int)

type SnippetInfo

type SnippetInfo struct {
	Description string `yaml:"description"`
	Command     string `yaml:"command"`
	Timestamp   int64  `yaml:"timestamp"`
	Hash        string `yaml:"-"`
	// Not supported for now
	Tag        []string `yaml:"tag"`
	Output     string   `yaml:"output"`
	PromptPass string   `yaml:"promptPass"`
}

func NewSnippet

func NewSnippet() *SnippetInfo

type Snippets

type Snippets struct {
	Db       *db.Storage
	Logger   *zerolog.Logger
	Snippets []SnippetInfo `yaml:"snippets"`
}

func (*Snippets) Load

func (snippets *Snippets) Load() (map[interface{}]interface{}, error)

Load reads yaml file.

func (*Snippets) Order

func (snippets *Snippets) Order()

Order snippets regarding SortBy option defined in config yaml Prefix "-" reverses the order, default is "recency", "+<expressions>" is the same as "<expression>"

func (*Snippets) SortByTimestamp

func (snippets *Snippets) SortByTimestamp()

func (*Snippets) ToString

func (snippets *Snippets) ToString() (string, error)

ToString returns the contents of yaml file.

Jump to

Keyboard shortcuts

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