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

Conversation

jopemachine
Copy link
Contributor

@jopemachine jopemachine commented Jul 21, 2020

Related Issue

Fixes #54

Usage

alfy.output([{
      title : "",
      arg: "",
      autocomplete: "",
      subtitle: "",
}], 1);

Comment

I made this PR because I think rerun property would be useful.


IssueHunt Summary

Referenced issues

This pull request has been submitted to:


@sindresorhus
Copy link
Owner

Please put some more effort into this.

@sindresorhus
Copy link
Owner

This will also need to be well documented in the readme and index.d.ts.

@sindresorhus
Copy link
Owner

A boolean argument will not be very readable at the callsite.

@jopemachine
Copy link
Contributor Author

jopemachine commented Jul 21, 2020

Thanks you for your quick reviewing!

A boolean argument will not be very readable at the callsite.

I guess maybe there is some misunderstanding.

This is not boolean argument.

That means if I put one in that factor, the script filter runs every second.

This is an interval value from run to next run. (entering the value of the run)

So, The output values for the functions below are as follows.

alfy.output([{
      title : "",
      arg: "",
      autocomplete: "",
      subtitle: "",
}], 3);

Result:

{
	"items": [
	{
			"title": "",
			"arg": "",
			"autocomplete": "",
			"subtitle": ""
	}],
	"rerun": 3
}

Shall I write some documentation about this function?

Or should I change the signature to increase usability?

@jopemachine
Copy link
Contributor Author

This will also need to be well documented in the readme and index.d.ts.

May I ask where is index.d.ts file?

It seems that I can't find index.d.ts in this repository.

@sindresorhus
Copy link
Owner

This is not boolean argument.

Just a typo. I meant number. My argument still stands. Not very readable. Should be an options-object.

@sindresorhus
Copy link
Owner

May I ask where is index.d.ts file?

Ah, I thought we had an index.d.ts here. Never mind.

@jopemachine
Copy link
Contributor Author

jopemachine commented Jul 21, 2020

Usage

    alfy.output([{
      title : "",
      arg: "",
      autocomplete: '',
      subtitle: "",
    }], { rerun : 1 });

So, I changed the usage like above as you mentioned.

It looks much better.

@jopemachine
Copy link
Contributor Author

jopemachine commented Jul 21, 2020

I've thought it would be good to add variables in the same way.

So, I expanded this PR's scope.

It seems that it is related with #43

Usage

    alfy.output([{
      title : "",
      arg: "",
      autocomplete: "",
      subtitle: "",
    }], { 
      rerun : 1,
      variables: {
        "fruit": "banana",
        "vegetable": "carrot",
      }
    });

Please let me know if there are still running out of documents or there is more to do.

@jopemachine jopemachine changed the title Support rerun (#54) Support rerun, variables option (#54) Jul 21, 2020
@jopemachine jopemachine force-pushed the Support-rerun branch 2 times, most recently from 10e084e to 9c9df8f Compare July 21, 2020 05:37
@sindresorhus
Copy link
Owner

Try to look at { rerun : 1 } without knowing anything about how it works. Is it clear enough what it does? I don't think so. It needs a clearer name.

@sindresorhus
Copy link
Owner

I've thought it would be good to add variables in the same way.

That should be a separate PR.

@jopemachine
Copy link
Contributor Author

Try to look at { rerun : 1 } without knowing anything about how it works. Is it clear enough what it does? I don't think so. It needs a clearer name.

So, how about rerun-interval?

index.js Outdated Show resolved Hide resolved
readme.md Outdated Show resolved Hide resolved
@jopemachine
Copy link
Contributor Author

jopemachine commented Jul 21, 2020

What about runInterval or rerunInterval?

I think It seems to imply that the script will be re-executed based on its interval.

@jopemachine jopemachine requested a review from sindresorhus July 21, 2020 07:14
@jopemachine jopemachine changed the title Support rerun, variables option (#54) Support rerun option (#54) Jul 21, 2020
@jopemachine
Copy link
Contributor Author

jopemachine commented Jul 22, 2020

I've been thinking about the proper variable name.

These are the variable names that I've thought about.


1 - runInterval or rerunInterval
2 - outputInterval orreOutputInterval
3 -updateInterval or updateOutputInterval
4 - scriptFilterRerunInterval
5 - updateEverySpecifiedSecond

If I still don't have a proper variable name at all, May I ask you to give me some a little advice?

I think it will be very useful to many people if this feature is merged.

@sindresorhus
Copy link
Owner

I would go with rerunInterval.

@sindresorhus
Copy link
Owner

Travis is failing

@jopemachine
Copy link
Contributor Author

Travis is failing

Okay. Let me look into it.

@jopemachine
Copy link
Contributor Author

It was an object-curly-spacing error.

Resolved it by removing the side whitespace of { and }.

@sindresorhus
Copy link
Owner

Since it's difficult to automatically test this, can you manually test that this new feature works?

@jopemachine
Copy link
Contributor Author

jopemachine commented Aug 11, 2020

Since it's difficult to automatically test this, can you manually test that this new feature works?

Sure.

Here is my code.

  alfy.output([
    {
      title: "Please wait until the caching process is finished...",
      arg: "error",
      autocomplete: "",
      subtitle: `This work could take several minutes.`,
    }
  ], { rerunInterval: 1 });

And here is the log.

[02:54:36.174] alfred-evernote-workflow[Script Filter] Queuing argument ''
[02:54:36.620] alfred-evernote-workflow[Script Filter] Script with argv '(null)' finished
[02:54:36.623] alfred-evernote-workflow[Script Filter] {
	"items": [
		{
			"title": "Please wait until the caching process is finished...",
			"arg": "error",
			"autocomplete": "",
			"subtitle": "This work could take several minutes."
		}
	],
	"rerun": 1
}
[02:54:37.636] alfred-evernote-workflow[Script Filter] Queuing argument ''
[02:54:38.055] alfred-evernote-workflow[Script Filter] Script with argv '(null)' finished
[02:54:38.057] alfred-evernote-workflow[Script Filter] {
	"items": [
		{
			"title": "Please wait until the caching process is finished...",
			"arg": "error",
			"autocomplete": "",
			"subtitle": "This work could take several minutes."
		}
	],
	"rerun": 1
}

In the log, in 02:54:36.623, 02:54:38.057 The script has been re-executed.
(Although it's not exact a second)

And If I leave Alfred like that, it will continue to re-run.

So, you can check rerunInterval property works well.

@sindresorhus sindresorhus changed the title Support rerun option (#54) Add rerunInterval option Aug 16, 2020
@sindresorhus sindresorhus merged commit de0213a into sindresorhus:master Aug 16, 2020
@jopemachine
Copy link
Contributor Author

Thank you for merging useful feature.

But, I think there was a mistake in the README.md update.

The range of rerun-interval value should be 0.1...5.0 according to this document., not to 0.1...0.5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support the rerun parameter
2 participants