alpaca
alpaca copied to clipboard
A compiler for Alfred workflows
Alpaca
Alpaca is a command line utility for building Alfred workflow bundles.
An alpaca project is an alpaca.yml file that defines the workflow, alongside any supporting files, such as scripts or images.
Note: Alpaca is still in the proof-of-concept phase. Huge portions of Alfred functionality are unimplemented.
Contents
- Installation
- Usage
alpaca pack
- Schema
- Example
- Root Schema
- Object Schema
applescriptclipboardkeywordopen-urlscriptscript-filter
- Script Schema
- Executable Script
- Inline Script
Installation
Download the latest release, or:
$ go get github.com/jclem/alpaca
Usage
alpaca pack <dir>
Pack an Alpaca project into an Alfred workflow. The workflow will be output into the current directory.
$ alpaca pack .
Schema
Example
This workflow uses a trigger "say" to say words passed as arguments. For example, the user might type "say hello world" into Alfred.
name: Say
objects:
trigger:
type: keyword
config:
keyword: say
argument: required
then: say
say:
type: script
config:
script:
content: say {query}
type: bash
Root Schema
nameThe name of the projectversionThe version of the projectauthorThe author of the project (i.e.Jonathan Clem <[email protected]>)bundle-idThe Alfred workflow bundle IDdescriptionA short description of the workflowreadmeA longer description of the workflow, seen when users import iturlA homepage URL for the workflowiconA project-relative path to an icon to use for the worflowvariablesA map of variable names and their default valuesobjectAn map of objects in the Alfred workflow. Each key is an object name.
Object Schema
iconA project-relative path to an icon for the objecttypeThe type of object this is. Currently partial support exists for:applescriptclipboardkeywordopen-urlscriptscript-filter
configA type-specific configuration object, see each type schema for detailsthenA string, list of strings, or a list of objects representing other objects to connect to, each objects having this schema:objectThe name of the object to connect to
applescript
cache(bool, defaulttrue) Whether to cache the compiled AppleScriptcontent(string) The content of the AppleScript
clipboard
text(string, default"{query}") The text to copy to the clipboard—use"{query}"for the exact query
keyword
keyword(string) The keyword that triggers this objectwith-space(bool, defaulttrue) Whether a space is required with this objecttitle(string) The title of the objectsubtitle(string) The subtitle of the objectargument(string) A string determining whether an argument is required. One of:requiredThe argument is requiredoptionalThe argument is optionalnoneNo argument is accepted
open-url
url(string) The URL to open. Use"{query}"for the exact query
script
scriptA script configuration object
script-filter
argument(string) A string determining whether an argument is required. One of:requiredThe argument is requiredoptionalThe argument is optionalnoneNo argument is accepted
argument-trim(string) Whether to trim the argument's whitespace. One of:autoArgument automatically trimmedoffArgument not trimmed
escaping([]string) A list of strings to escape in the query text, if the script object'sarg-typeisquery. Any of:spacesbackquotesdouble-quotebracketssemicolonsdollarsbackslashes
ignore-empty-argument(bool) Whether an empty argument (whenarg-typeisargvin script config) is omitted fromargv(whenfalse, it will be an empty string)keyword(string) The keyword that triggers this objectrunning-subtitle(string) A subtitle to display while this filter runssubtitle(string) A subtitle for this objecttitle(string) A title for this objectwith-space(bool, defaulttrue) Whether a space is required with this objectalfred-filters-resultsAn object describing how Alfred filters results (it does not if this is omitted):mode(string) The mode Alfred uses to filter results. One of:exact-boundaryexact-startword-match
run-behaviorAn object describing behavior of the script runimmediate(bool) Whether to run immediately always for the first character typedqueue-mode(string) A mode for how script runs are queued. One of:waitWait for previous run to completeterminateTerminate previous run immediately and start a new one
queue-delay(string) A delay mode for queueing script runs. One of:immediateNo delayautomaticAutomatic after last character typed100ms100ms after last character typed200ms200ms after last character typed300ms300ms after last character typed400ms400ms after last character typed500ms500ms after last character typed600ms600ms after last character typed700ms700ms after last character typed800ms800ms after last character typed900ms900ms after last character typed1000ms1000ms after last character typed
scriptA script configuration object
Script Schema
There are a few types of script schemas possible, in addition to these options:
Executable Script
This version executes the script at the given path (it must be executable).
path(string) The path to the script
Inline Script
This version executes an inline script.
arg-type(string) The way the argument is passed to the script. One of:queryInterpolated as (query)argvPassed into process arguments
content(string) The content of the scripttype(string) The type of script, one of:bashphprubypythonperlzshosascript-asosascript-js