Jump to content

Anyway to take argument and run separate set of workflows?


Recommended Posts

So I'm not sure if this is possible, but I'm looking to run an Alfred workflow where, depending on the argument, it will open up a different set of urls.

 

I have a keyword set up with the argument required, and I'm looking to take that argument and then if its one of 3 options, then open up a specific set of URLs in Chrome.  The use case here being I want to open up the local testing URLs when the command is "dev" or all of the production testing URLs when "prod" is passed in.

 

I can't figure out how to pass that part of the query to a specific set of Actions.

Link to comment

So I'm not sure if this is possible, but I'm looking to run an Alfred workflow where, depending on the argument, it will open up a different set of urls.

 

I have a keyword set up with the argument required, and I'm looking to take that argument and then if its one of 3 options, then open up a specific set of URLs in Chrome.  The use case here being I want to open up the local testing URLs when the command is "dev" or all of the production testing URLs when "prod" is passed in.

 

I can't figure out how to pass that part of the query to a specific set of Actions.

Could you use three different keywords? One could be 'keyword dev', another 'keyword prod', and finally 'keyword third command'; each could be linked to a different action set.

Link to comment

I'm trying to keep it to 1 workflow using the same keyword with 3 different arguments.  So to run it, "site dev" and it will launch 3 urls for testing and then I run "site qa" and it runs 3 different urls for testing and then I run "site prod" and it will run 3 different urls.  I realize I could make this work with 3 different keywords linking to the different actions, but that kind of takes away the fun of workflows.

Link to comment

I'm trying to keep it to 1 workflow using the same keyword with 3 different arguments.  So to run it, "site dev" and it will launch 3 urls for testing and then I run "site qa" and it runs 3 different urls for testing and then I run "site prod" and it will run 3 different urls.  I realize I could make this work with 3 different keywords linking to the different actions, but that kind of takes away the fun of workflows.

Quick note: you can use multiple keyword objects in a single workflow (in case you didn't know already)

If you don't want to use multiple keywords, you'll probably need to use a 'Run Script' object that looks at the argument, compares it to a list of commands, and launches the appropriate websites with an 'open' command in the script.

I really don't understand why you wouldn't use multiple keywords; it saves work, prevents errors, and is likely faster than the above method. It's just cleaner IMO to use built in functionality from Alfred :P

Link to comment

If I wanted to use a script to parse the input data, how would I return that data to the "Actions"?

 

Well since you are doing something easy, just trying to open urls, you could create a workflow with a single keyword (or you could always use a script filter to keep from having to type the additional input) then pass that to an Action->Run Script. Inside of there you could do...

userinput="{query}"

if [ $userinput == "dev" ]; then
 //code to open 3 urls from bash
elif [ $userinput == "qa" ]; then
 //code to open 3 urls from bash
elif [ $userinput == "prod" ]; then
 //code to open 3 urls from bash
else
 //maybe display an error?
fi

 

To open the urls.. if Chrome is your default browser, a simple:

open http://url1.com
open http://url2.com
open http://url3.com

 

If Chrome is not your default browser then you would have to specify what to open the URLs in. Similar to this:

open -a /Applications/Google\ Chrome.app http://url1.com
open -a /Applications/Google\ Chrome.app http://url2.com
open -a /Applications/Google\ Chrome.app http://url3.com
Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...