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 root level variables option #122

Closed
wants to merge 6 commits into from

Conversation

jopemachine
Copy link
Contributor

@jopemachine jopemachine commented Aug 16, 2020

Related Issue

Fixes #43

Usage

alfy.output(
	[
		{
			title: 'API key register',
		}
	],
	{ 
		variables: {
            "apiKey": apiKey,
            "error": errorOccured
        } 
	}
);

Test

Here is test code.

const alfy = require("alfy");

const apiKey = "some API key";
const errorOccured = false;

alfy.output(
	[
		{
			title: 'API key register',
		}
	],
	{ 
		variables: {
            "apiKey": apiKey,
            "error": errorOccured
        } 
	}
);

And this is the debug log.

I logged {var:apiKey}, {allVars}.

[16:07:39.158] alfred-evernote-workflow[Script Filter] Queuing argument ''
[16:07:39.878] alfred-evernote-workflow[Script Filter] Script with argv '(null)' finished
[16:07:39.880] alfred-evernote-workflow[Script Filter] {
	"items": [
		{
			"title": "API key register"
		}
	],
	"variables": {
		"apiKey": "some API key",
		"error": false
	}
}
[16:07:39.944] alfred-evernote-workflow[Script Filter] Processing complete
[16:07:39.945] alfred-evernote-workflow[Script Filter] Passing output '' to Debug
[16:07:39.946] alfred-evernote-workflow[Debug] some API key, {allVars}

You can check variables property works by the above test log.

Please let me know if there's anything lacking.

@jopemachine jopemachine changed the title Add variables option Add Root level variables option Aug 18, 2020
@jopemachine jopemachine changed the title Add Root level variables option Add root level variables option Aug 18, 2020
@jopemachine
Copy link
Contributor Author

jopemachine commented Aug 18, 2020

And as for item-level variables,

I think we don't need additional work because we can handle it by the present's code.

If you don't think so, or there is something we need to do, pls let me know.

@sindresorhus
Copy link
Owner

I think you need to put some more work into the docs.

@jopemachine
Copy link
Contributor Author

jopemachine commented Aug 23, 2020

I think you need to put some more work into the docs.

Thank you for your feedback.

I've added some info about item-level variable.

@jopemachine
Copy link
Contributor Author

Do we still need more work about docs?

If so, could I get some hints about what should be included in the document?

@stdavis
Copy link

stdavis commented Sep 1, 2020

This would be super-helpful when attempting to post a message using Alfred's "Post Notification" output. Right now, the best I can get is a stringified object...
image

@sindresorhus
Copy link
Owner

@stdavis If you need this, help reviewing this PR is welcome :)

@sindresorhus
Copy link
Owner

I think you need to put some more work into the docs.

This still applies.

@jopemachine
Copy link
Contributor Author

jopemachine commented Oct 11, 2020

I've added an example (email-validate) using root-level variable to README.md.

To prevent unnecessary complexity of README, the email-validate example excluded logic to determine whether the input is the valid email by regex.

In fact, the screenshot I just uploaded doesn't look good.
(Especially, compared to other neat screenshots)

But, I updated this because I want to know whether this example explains enough how to use variables.

I would appreciate it if you let me know if this example still doesn't explain enough how to use variable to users.

@jopemachine
Copy link
Contributor Author

To be honest, I don't have an idea about how to reinforce the document.
I would be very grateful if anyone could do the work or give me some advice :)

Base automatically changed from master to main January 23, 2021 07:48
@sindresorhus
Copy link
Owner

I appreciate the effort, but it's simply not close to being mergeable and I don't currently have the time to clean it up.

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 setting Alfred variables with alfy.output
3 participants