snippet

package
v0.1.0-alpha Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2018 License: MIT Imports: 13 Imported by: 4

Documentation

Index

Constants

View Source
const (
	SHELL_BASH        = "bash"
	SHELL_ZSH         = "zsh"
	SHELL_UNSUPPORTED = "unsupported"
)

Variables

View Source
var TempHistFile = "/tmp/corgi.hist"
View Source
var TemplateParamsRegex = `<([^(<>|\s)]+)>`

Functions

func FillTemplates

func FillTemplates(c string, tfMap *TemplateFieldMap) string

func ParseFileToStringArray

func ParseFileToStringArray(filePath string, parser CommandParser) ([]string, error)

func ReadShellHistory

func ReadShellHistory() ([]string, error)

func RemoveHistFile

func RemoveHistFile() error

func SetUpHistFile

func SetUpHistFile(histCmds []string) error

Types

type Answerable

type Answerable interface {
	AskQuestion(options ...interface{}) error
}

type BashCmdParser

type BashCmdParser struct{}

func (BashCmdParser) Parse

func (b BashCmdParser) Parse(line string) string

type CommandParser

type CommandParser interface {
	Parse(string) string
}

func GetCmdParser

func GetCmdParser(shellType string) (CommandParser, error)

type Snippet

type Snippet struct {
	Title string      `json:"title"`
	Steps []*StepInfo `json:"steps"`
	// contains filtered or unexported fields
}

func LoadSnippet

func LoadSnippet(filePath string) (*Snippet, error)

func NewSnippet

func NewSnippet(title string, cmds []string) (*Snippet, error)

func (*Snippet) AskQuestion

func (snippet *Snippet) AskQuestion(options ...interface{}) error

func (*Snippet) Execute

func (snippet *Snippet) Execute() error

func (*Snippet) GetFilePath

func (snippet *Snippet) GetFilePath() string

func (*Snippet) Save

func (snippet *Snippet) Save(snippetsDir string) error

type Snippets

type Snippets struct {
	Snippets []*jsonSnippet `json:"snippets"`
	// contains filtered or unexported fields
}

func LoadSnippets

func LoadSnippets(filePath string) (*Snippets, error)

func (*Snippets) AddSnippet

func (snippets *Snippets) AddSnippet(snippet *Snippet)

func (*Snippets) FindSnippet

func (snippets *Snippets) FindSnippet(title string) (*Snippet, error)

func (*Snippets) Save

func (snippets *Snippets) Save() error

type StepInfo

type StepInfo struct {
	Command           string `json:"command"`
	Description       string `json:"description,omitempty"`
	ExecuteConcurrent bool   `json:"execute_concurrent"`
}

func NewStepInfo

func NewStepInfo(command string) *StepInfo

func (*StepInfo) AskQuestion

func (step *StepInfo) AskQuestion(options ...interface{}) error

func (*StepInfo) Execute

func (step *StepInfo) Execute() error

TODO: add concurrent execution

type TemplateField

type TemplateField struct {
	FieldName string `json:"field_name"`
	Value     string `json:"default_value"`
}

func (*TemplateField) AskQuestion

func (tf *TemplateField) AskQuestion(options ...interface{}) error

type TemplateFieldMap

type TemplateFieldMap map[string]*TemplateField

func ParseTemplateFields

func ParseTemplateFields(c string) TemplateFieldMap

func (TemplateFieldMap) AddTemplateField

func (tfMap TemplateFieldMap) AddTemplateField(t *TemplateField)

type ZshCmdParser

type ZshCmdParser struct{}

func (ZshCmdParser) Parse

func (z ZshCmdParser) Parse(line string) string

Jump to

Keyboard shortcuts

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