Add the following code to your project's shard.yml under:
dependencies
to use in production
- OR -
development_dependencies
to use in development
Create Alfred Workflows in Crystal with ease.
Add this to your application's shard.yml
:
dependencies:
alfred:
github: kiliankoe/alfred.cr
You need Alfred 3 with the paid Powerpack upgrade.
Here's a quick and dirty example, more documentation will be added soon 😛
require "alfred"
item = Alfred::Item.new do |i|
i.title = "An awesome title"
i.subtitle = "An awesome subtitle"
i.arg = "argument"
mod = Alfred::Mod.new do |m|
m.arg = "mod arg cmd"
m.subtitle = "some other subtitle"
end
i.add_mod Alfred::ModKey::CMD.to_s, mod
end
Alfred.output item
# => {"items":[{"title":"An awesome title","subtitle":"An awesome subtitle","arg":"argument","mods":{"cmd":{"valid":true,"arg":"mod arg cmd","subtitle":"some other subtitle"}}}]}
Alfred workflows using alfred.cr
Shoutout goes to BenchR267 with whom I explored much of Alfred's quirks (goalfred came out of that 😊) and alfy, from which I shamelessly stole (as in imitation is the sincerest form of flattery) the basic API.