espanso
is a Go library without dependencies for creating packages for
espanso, the cross-platform Text Expander.
import "github.com/timorunge/espanso"
func main() {
var (
matches espanso.Matches
version = "0.1.0"
)
m1 := espanso.NewMatch()
m1.SetTrigger(":espanso")
m1.SetReplace("Hi there!")
matches = append(matches, m1)
m2 := espanso.NewMatch()
m2.SetTrigger(":br")
m2.SetReplace("Best Regards,\nJon Snow")
matches = append(matches, m2)
m3 := espanso.NewMatch()
m3.SetTrigger(":br")
m3.SetReplace("Best Regards,\nJon Snow")
matches = append(matches, m3)
m4 := espanso.NewMatch()
m4.SetTrigger("alh")
m4.SetReplace("although")
m4.SetPropagateCase(true)
m4.SetWord(true)
matches = append(matches, m4)
m5 := espanso.NewMatch()
m5.SetTrigger(":cat")
m5.SetImagePath("/path/to/image.png")
matches = append(matches, m5)
p := espanso.NewPackage()
p.SetName("my-package")
p.SetParent("default")
p.SetMatches(matches)
p.SetVersion(version)
if err := p.Write(); err != nil {
panic(err)
}
r := espanso.NewReadme()
r.SetAuthor("Timo Runge")
r.SetLongDesc(`Long description for my espanso package. Can be Markdown.`)
r.SetName(p.Name())
r.SetRepo("https://github.com/timorunge/espanso")
r.SetShortDesc("Short description for my espanso package.")
r.SetTitle("My Package")
r.SetVersion(version)
if err := r.Write(p.Name()); err != nil {
panic(err)
}
}
func main() {
var (
matches = []string{
":espanso", "Hi there!",
":br", "Best Regards,\nJon Snow",
}
version = "0.1.0"
)
p := espanso.NewPackage()
p.SetName("my-package")
p.SetParent("default")
p.SetMatches(espanso.DictToMatches(matches))
p.SetVersion(version)
if err := p.Write(); err != nil {
panic(err)
}
r := espanso.NewReadme()
r.SetAuthor("Timo Runge")
r.SetLongDesc(`Long description for my espanso package. Can be Markdown.`)
r.SetName(p.Name())
r.SetRepo("https://github.com/timorunge/espanso")
r.SetShortDesc("Short description for my espanso package.")
r.SetTitle("My Package")
r.SetVersion(version)
if err := r.Write(p.Name()); err != nil {
panic(err)
}
}
BSD 3-Clause "New" or "Revised" License
- Timo Runge