Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add rerunInterval option #121

Merged
merged 11 commits into from
Aug 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ alfy.alfred = {

alfy.input = process.argv[2];

alfy.output = items => {
console.log(JSON.stringify({items}, null, '\t'));
alfy.output = (items, {rerunInterval} = {}) => {
console.log(JSON.stringify({items, rerun: rerunInterval}, null, '\t'));
};

alfy.matches = (input, list, item) => {
Expand Down
30 changes: 29 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ Type: `string`

Input from Alfred. What the user wrote in the input box.

#### output(list)
#### output(list, options?)

Return output to Alfred.

Expand All @@ -204,6 +204,34 @@ alfy.output([
]);
```

##### options

Type: `object`

sindresorhus marked this conversation as resolved.
Show resolved Hide resolved
###### rerunInterval

Type: `number` *(seconds)*\
Values: `0.1...0.5`

A script can be set to re-run automatically after some interval. The script will only be re-run if the script filter is still active and the user hasn't changed the state of the filter by typing and triggering a re-run. [More info.](https://www.alfredapp.com/help/workflows/inputs/script-filter/json/)

For example, it could be used to update the progress of a particular task:

```js
alfy.output(
[
{
title: 'Downloading Unicorns…',
subtitle: `${progress}%`,
}
],
{
// Re-run and update progress every 3 seconds.
rerunInterval: 3
}
);
```

<img src="media/screenshot-output.png" width="694">

#### log(value)
Expand Down