Skip to content

espanso is a Go library for creating packages for espanso, the cross-platform Text Expander.

License

Notifications You must be signed in to change notification settings

timorunge/espanso

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

espanso

Go Report Build Status

espanso is a Go library without dependencies for creating packages for espanso, the cross-platform Text Expander.

Install

import "github.com/timorunge/espanso"

Examples

General

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)
	}
}

DictToMatches

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)
	}
}

License

BSD 3-Clause "New" or "Revised" License

Author Information

  • Timo Runge

About

espanso is a Go library for creating packages for espanso, the cross-platform Text Expander.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages