A more elegant way to develop with Alfred Workflow
TOC
AlfredOutputBuilder can help you build a standard Alfred Workflow output easily. Natural IntelliSense auto-complete with TypeScript and no longer need to look at the official Script Filter JSON Format document all the time
import { AlfredOutputBuilder } from 'alfred-tools'
const output = new AlfredOutputBuilder()
output
.append('My first item', 'https://google.com', 'subtitle of first item', {
valid: false,
icon: {
path: './icon.png'
}
})
.append('Second item')
.print()
params
: <AlfredOutputItem> optional Alfred output option config- returns: <AlfredOutput>
title
: <string> option titlearg
: <string> option arg, pass to next node as an argumentsubtitle
: <string> option subtitleparams
: <AlfredOutputItem> optional alfred output option config
Append a single option
output
.append('first option', 'A', 'choose this one will get A')
.print()
items
: <AlfredOutputItem[]> array of alfred output option
Shortcut for output.append().append()
title
: <string> option titlesubtitle
: <string> option subtitleicon
: <string> absolute path of icon for option
Append a static option more easily
output.tips('Not support', 'Please install dependencies first', path.resolve(__dirname, './icon.png'))
Shortcut for output.tips(), built-in icon for information
Shortcut for output.tips(), built-in icon for alarm
Clear all existing options
Show output with Alfred options
Storage your history options or just read common links from config.
const { RecentlyUsed, AlfredOutputBuilder } = require('alfred-tools');
const { detectURL } = require('./endpoint');
const pageHistory = RecentlyUsed.use('history.json', 10);
const output = new AlfredOutputBuilder()
output.append('First Row')
const histories = pageHistory.read().map(url => ({
title: url,
arg: url,
subtitle: detectURL(url),
icon: {
path: './assets/ic_history.png',
},
}));
output.append(histories)
Returns an instance of RecentlyUsed
Read the recently used list from the local file, you can specify a maximum limit
nextRecord
: <object> object to be store
Updating a new record item into the local file
data
: <object[]> the whole data to replace
Overwrite all of the data
Clean up all of the data
Provide a constant history to read, record, and replace the operation history, defaults save at .cache/history.json
const { history } = require('alfred-tools');
const output = new AlfredOutputBuilder()
output.append('First Row')
output.append(history.read())
limit
: <number> maximum limit of the records- returns: <AlfredOutputItem[]>
Read the history list from the local file, you can specify a maximum limit
data
: <HistoryConfig> object to be store
Updating a new record item into the local file
params
: <AlfredOutputItem> optional Alfred output option config
Setup the default configuration of the history options
Clean up all of the histories
MIT