sman

package
v1.0.1-0...-c9d15a8 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2021 License: GPL-3.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var RootCmd = &cobra.Command{
	Use:   "sman",
	Short: "CLI Snippet Manager (" + version + ")",
	Long:  ``,
}

RootCmd for cobra

Functions

func Execute

func Execute()

Execute for cobra

Types

type Config

type Config struct {
	SnippetDir                 string
	ExecConfirm, AppendHistory bool
	LsFilesColor               *color.Color
}

Config file struct

type Placeholder

type Placeholder struct {
	Name, Desc, Input string
	Options           []string
	Patterns          []string
}

Placeholder struct

func (*Placeholder) AddPattern

func (p *Placeholder) AddPattern(pattern string)

AddPattern adds new pattern to Patterns slice if not exists

func (*Placeholder) DisplayName

func (p *Placeholder) DisplayName() string

DisplayName returns formatted name

func (*Placeholder) ParseOptions

func (p *Placeholder) ParseOptions(in string)

ParseOptions splits string by comma and sets Options value

func (*Placeholder) SetInput

func (p *Placeholder) SetInput(input string)

SetInput sets input variable of Placeholder. If input is string and Placeholder has options, we try to set option value. The same way, if input is empty we try to set first option as input, assuming default value.

type Snippet

type Snippet struct {
	Desc, Command, Name, Do, File string
	Tags                          []string
	Placeholders                  []Placeholder
}

Snippet struct

func (*Snippet) DisplayCommand

func (s *Snippet) DisplayCommand() (out string)

DisplayCommand returns formatted command

func (*Snippet) ParseCommand

func (s *Snippet) ParseCommand()

ParseCommand reads snippet command and creates Placeholders instance

func (*Snippet) ReplacePlaceholders

func (s *Snippet) ReplacePlaceholders()

ReplacePlaceholders replaces placeholders patterns by placeholders input

func (*Snippet) SetInputs

func (s *Snippet) SetInputs(inputs []string)

SetInputs receives slice of inputs and sets Placeholders inputs in the same order

type SnippetSlice

type SnippetSlice []Snippet

SnippetSlice for sorting

func (SnippetSlice) Len

func (s SnippetSlice) Len() int

func (SnippetSlice) Less

func (s SnippetSlice) Less(a, b int) bool

func (SnippetSlice) Swap

func (s SnippetSlice) Swap(a, b int)

Jump to

Keyboard shortcuts

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