- Notifications
You must be signed in to change notification settings - Fork48
Go library for Alfred 3 + 4 workflows
License
deanishe/awgo
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Full-featured library to build lightning-fast workflows in a jiffy.
- Full support for Alfred 3 & 4
- Bi-directional interface toworkflow's config
- Fluent API for generatingScript Filter JSON
- Fuzzy sorting/filtering
- Simple, powerful API forcaching/saving workflow data
- Keychain API tosecurely store (and sync) sensitive data
- Helpers toeasily run scripts and script code
- Workflowupdate API with built-in support forGitHub &Gitea
- Pre-configured logging for easier debugging, with a rotated log file
- Catches panics, logs stack trace and shows user an error message
- "Magic" queries/actions for simplified development and user support
- macOSsystem icons
Install AwGo with:
go get -u github.com/deanishe/awgo
Typically, you'd call your program's main entry point viaWorkflow.Run()
.This way, the library will rescue any panic, log the stack trace and showan error message to the user in Alfred.
program.go:
package main// Package is called awimport"github.com/deanishe/awgo"// Workflow is the main APIvarwf*aw.Workflowfuncinit() {// Create a new Workflow using default settings.// Critical settings are provided by Alfred via environment variables,// so this *will* die in flames if not run in an Alfred-like environment.wf=aw.New()}// Your workflow starts herefuncrun() {// Add a "Script Filter" resultwf.NewItem("First result!")// Send results to Alfredwf.SendFeedback()}funcmain() {// Wrap your entry point with Run() to catch and log panics and// show an error in Alfred instead of silently dyingwf.Run(run)}
In the Script Filter's Script box (Language = /bin/bash with input asargv):
./program"$1"
Read the docson pkg.go.dev.
Check out theexample workflows (docs), whichshow how to use AwGo. Use one as a template to get your own workflow up andrunning quickly.
The library (and therefore the unit tests) rely on being run in a minimallyAlfred-like environment, as they pull configuration options from the environmentvariables set by Alfred.
This means that if you want to run AwGo-based code outside Alfred, e.g. in yourshell, you must set at least the following environment variables to meaningfulvalues, or the library will panic:
alfred_workflow_bundleid
alfred_workflow_cache
alfred_workflow_data
And if you're using the update API, also:
alfred_workflow_version
alfred_version
(not needed for Alfred 4+)
To create a sufficiently Alfred-like environment, you cansource
theenv.sh
script in the project root or run unit tests via therun-tests.sh
script(which also sets up an appropriate environment before callinggo test
).
This library is released under theMIT licence. It was built withneovim andGoLand by JetBrains.
The icon is based on theGo Gopher byRenee French.
About
Go library for Alfred 3 + 4 workflows