Documentation ¶
Index ¶
- Constants
- Variables
- func FillTemplates(c string, tfMap *TemplateFieldMap) string
- func ParseFileToStringArray(filePath string, parser CommandParser) ([]string, error)
- func ReadShellHistory() ([]string, error)
- func RemoveHistFile() error
- func SetUpHistFile(histCmds []string) error
- type Answerable
- type BashCmdParser
- type CommandParser
- type FishCmdParser
- type Snippet
- func (snippet *Snippet) AskQuestion(options ...interface{}) error
- func (snippet *Snippet) BuildTemplateFieldMap() TemplateFieldMap
- func (snippet *Snippet) ConvertToShellScript() string
- func (snippet *Snippet) Describe()
- func (snippet *Snippet) Execute(options ...interface{}) error
- func (snippet *Snippet) Export(outputPath string, fileType string) error
- func (snippet *Snippet) GetFilePath() string
- func (snippet *Snippet) ParseStepRangeToIdx(stepRange string) (int, int, error)
- func (snippet *Snippet) Save(snippetsDir string) error
- type SnippetsMeta
- func (sm *SnippetsMeta) DeleteSnippet(title string) error
- func (sm *SnippetsMeta) FindSnippet(title string) (*Snippet, error)
- func (sm *SnippetsMeta) GetSnippetTitles() []string
- func (sm *SnippetsMeta) Save() error
- func (sm *SnippetsMeta) SaveNewSnippet(snippet *Snippet) error
- func (sm *SnippetsMeta) SetFileLoc(fileLoc string)
- func (sm *SnippetsMeta) SetSnippetsDir(path string)
- func (sm *SnippetsMeta) SyncWithSnippets() error
- type StepInfo
- type TemplateField
- type TemplateFieldMap
- type ZshCmdParser
Constants ¶
View Source
const ( SHELL_BASH = "bash" SHELL_ZSH = "zsh" SHELL_FISH = "fish" SHELL_UNSUPPORTED = "unsupported" )
View Source
const ( EXPORT_TYPE_JSON = "json" EXPORT_TYPE_SHELL = "shell" )
Variables ¶
View Source
var ( MissingDefaultValueError = errors.New("missing default value for template field") InvalidStepRangeError = errors.New("step range specified is invalid") )
View Source
var TempHistFile = "/tmp/corgi.hist"
View Source
var TemplateParamsRegex = `<([^(<>)]+)>`
Functions ¶
func FillTemplates ¶
func FillTemplates(c string, tfMap *TemplateFieldMap) string
func ParseFileToStringArray ¶
func ParseFileToStringArray(filePath string, parser CommandParser) ([]string, error)
func ReadShellHistory ¶
func RemoveHistFile ¶
func RemoveHistFile() error
func SetUpHistFile ¶
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 ¶
func GetCmdParser ¶
func GetCmdParser(shellType string) (CommandParser, error)
type FishCmdParser ¶ added in v0.2.3
type FishCmdParser struct{}
func (FishCmdParser) Parse ¶ added in v0.2.3
func (f FishCmdParser) Parse(line string) string
type Snippet ¶
type Snippet struct { Title string `json:"title"` Steps []*StepInfo `json:"steps"` // contains filtered or unexported fields }
func LoadSnippet ¶
func (*Snippet) AskQuestion ¶
func (*Snippet) BuildTemplateFieldMap ¶
func (snippet *Snippet) BuildTemplateFieldMap() TemplateFieldMap
func (*Snippet) ConvertToShellScript ¶ added in v0.2.3
func (*Snippet) GetFilePath ¶
func (*Snippet) ParseStepRangeToIdx ¶
type SnippetsMeta ¶
type SnippetsMeta struct { Snippets []*jsonSnippet `json:"snippets"` IsMetaDirty bool `json:"is_meta_dirty"` // contains filtered or unexported fields }
func (*SnippetsMeta) DeleteSnippet ¶
func (sm *SnippetsMeta) DeleteSnippet(title string) error
func (*SnippetsMeta) FindSnippet ¶
func (sm *SnippetsMeta) FindSnippet(title string) (*Snippet, error)
func (*SnippetsMeta) GetSnippetTitles ¶
func (sm *SnippetsMeta) GetSnippetTitles() []string
func (*SnippetsMeta) Save ¶
func (sm *SnippetsMeta) Save() error
func (*SnippetsMeta) SaveNewSnippet ¶
func (sm *SnippetsMeta) SaveNewSnippet(snippet *Snippet) error
Save new snippet into snippetsDir and update snippets meta file
func (*SnippetsMeta) SetFileLoc ¶ added in v0.2.4
func (sm *SnippetsMeta) SetFileLoc(fileLoc string)
func (*SnippetsMeta) SetSnippetsDir ¶ added in v0.2.4
func (sm *SnippetsMeta) SetSnippetsDir(path string)
func (*SnippetsMeta) SyncWithSnippets ¶ added in v0.2.4
func (sm *SnippetsMeta) SyncWithSnippets() error
type StepInfo ¶
type StepInfo struct { Command string `json:"command"` Description string `json:"description,omitempty"` }
func NewStepInfo ¶
func (*StepInfo) AskQuestion ¶
func (*StepInfo) ConvertToShellScript ¶ added in v0.2.3
func (step *StepInfo) ConvertToShellScript(templates *TemplateFieldMap) string
func (*StepInfo) Execute ¶
func (step *StepInfo) Execute(templates *TemplateFieldMap, options ...interface{}) error
TODO: add concurrent execution valid options include 'useDefaultVal' indicated by the --use-default flag
type TemplateField ¶
func (*TemplateField) AskQuestion ¶
func (tf *TemplateField) AskQuestion(options ...interface{}) error
type TemplateFieldMap ¶
type TemplateFieldMap map[string]*TemplateField // map from field name to template field object
func ParseTemplateFieldsMap ¶
func ParseTemplateFieldsMap(c string) TemplateFieldMap
func (TemplateFieldMap) AddTemplateFieldIfNotExist ¶
func (tfMap TemplateFieldMap) AddTemplateFieldIfNotExist(t *TemplateField)
type ZshCmdParser ¶
type ZshCmdParser struct{}
func (ZshCmdParser) Parse ¶
func (z ZshCmdParser) Parse(line string) string
Click to show internal directories.
Click to hide internal directories.