Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Categories ¶
type Categories []Category
Categories is a collection of Category
func (Categories) Less ¶
func (c Categories) Less(i, j int) bool
Less compares two Category in the Categories and returns bool true if i is less than j
func (Categories) ToSnippets ¶
func (c Categories) ToSnippets() *Snippets
ToSnippets will collect all the Snippets in the Categories
type Preferences ¶
type Preferences struct {
DefaultFile string `json:"defaultFile"` // users default snippets file
}
Preferences represents a users preferences.
func ReadPreferences ¶
func ReadPreferences(filename string) (*Preferences, error)
ReadPreferences reads the file indicated by filename and returns a *Preferences structure. If the filename is empty it will look for the default preferences file. If no file can be be found or the file is malformed an error is returned.
func (*Preferences) Write ¶ added in v1.0.0
func (p *Preferences) Write(filename string) error
Write the preferences as JSON to filename.
type SetCategories ¶
type SetCategories interface {
Categories(categories *Categories)
}
SetCategories is an interface indicating the ability to set Categories
type Snippet ¶
type Snippet struct { Category string `json:"category"` // category of the snippet Title string `json:"title"` // title of the snippet Body string `json:"body"` // body of the snippet }
Snippet defines a snippet
type Snippets ¶
type Snippets []Snippet
Snippets is a collection of Snippet
func ReadSnippets ¶
ReadSnippets accepts a filename, reads from the file and returns the Snippets found in the file.
func (Snippets) ByCategory ¶
func (s Snippets) ByCategory() Categories
ByCategory splits Snippets into their Category.
func (*Snippets) WriteSnippets ¶
WriteSnippets writes Snippets to the file named.