sindresorhus Posted July 3, 2016 Share Posted July 3, 2016 (edited) Currently, if I output the following: {"items": [ { "title": "Foo", "arg": "unicorn" } ]} I have to handle the `unicorn` arg in a connected output action in the workflow. It would be useful to be able to dynamically handle it without needing to create an output action. This can be useful for very dynamic results and creating reusable modules that create output with different actions. I propose adding a `script` property to the JSON format that when specified makes it not pass the output to any connected output action (like `valid: false`) and instead executes the `script` and passes `arg` to it. {"items": [ { "title": "Foo", "arg": "unicorn", "script": "run-foo.sh" } ]} This would make script filters a lot more powerful. Edited July 3, 2016 by sindresorhus Link to comment Share on other sites More sharing options...
deanishe Posted July 9, 2016 Share Posted July 9, 2016 (edited) This can already be achieved in various ways by using workflow variables and/or setting arg to a shell command. There's no reason you can't create a Run Script Action with Language = /bin/bash and Script = {query} and then set arg in your JSON output to run-foo.sh myinput. You just need to take care of any necessary escaping yourself. Or you could set a bunch of variables and use a JSON Config Utility to dynamically configure the following Action. What I generally do is write my workflows as command-line programs with various arguments/modes, like --search or --open, that correspond to the workflow's Script Filters and/or Run Scripts. If you also connect the options to environment variables, e.g. MYPROG_SEARCH=wallop is equivalent to ./myprog --search wallop, then you can use workflow variables to connect as many Script Filters as you like to a single Run Script Action that just says ./myprog. Edited July 9, 2016 by deanishe Link to comment Share on other sites More sharing options...
sindresorhus Posted August 3, 2016 Author Share Posted August 3, 2016 @deanishe I'm aware of this, but I was looking for a way to do it completely programmatically without having to resort to any more workflow nodes or variables. In Alfy, I would have liked to create some reusable dynamic menus that users could make use of without having to add anything extra in the workflow view. Link to comment Share on other sites More sharing options...
deanishe Posted August 3, 2016 Share Posted August 3, 2016 If you wrote the framework, you can intercept the input from Alfred and show whatever you want.Set valid=false and arg=alfy:runscript:name-of-script.sh (or whatever) and have your library extract and handle such commands before calling the workflow proper. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now