https://github.com/pascalw/go-alfred
Utility library for creating lightning fast Alfred 2 workflows
https://github.com/pascalw/go-alfred
Last synced: about 1 year ago
JSON representation
Utility library for creating lightning fast Alfred 2 workflows
- Host: GitHub
- URL: https://github.com/pascalw/go-alfred
- Owner: pascalw
- Created: 2013-06-22T19:59:46.000Z (almost 13 years ago)
- Default Branch: master
- Last Pushed: 2016-09-28T18:09:55.000Z (over 9 years ago)
- Last Synced: 2025-03-24T04:13:17.587Z (about 1 year ago)
- Language: Go
- Size: 2.93 KB
- Stars: 26
- Watchers: 2
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# go-alfred
Go-alfred is a utility library for quickly writing lightning fast [Alfred 2](http://www.alfredapp.com/) workflows using Golang.
## Example usage
```go
package main
import (
"os"
"github.com/pascalw/go-alfred"
"net/http"
"io/ioutil"
"encoding/json"
)
func main() {
queryTerms := os.Args[1:]
// optimize query terms for fuzzy matching
alfred.InitTerms(queryTerms)
// create a new alfred workflow response
response := alfred.NewResponse()
repos := getRepos()
for _, repo := range repos {
// check if the repo name fuzzy matches the query terms
if ! alfred.MatchesTerms(queryTerms, repo.Name) { continue }
// it matched so add a new response item
response.AddItem(&alfred.AlfredResponseItem{
Valid: true,
Uid: repo.URL,
Title: repo.Name,
Arg: repo.URL,
})
}
// finally print the resulting Alfred Workflow XML
response.Print()
}
```
See [Example/](https://github.com/pascalw/go-alfred/blob/master/example/example.go) for details.