Jump to content

Recommended Posts

Hello my name is Ralf and I'm from good old germany.

 

I've written a dandelion ( git deployment ruby gem ) Workflow and would like to get some feedback, because I think I'm not doing it right :-)

Here is some code

 

dandelion deploy

# Load profile
cd ~/
. .bash_profile

# Load multiple parameters
read PROJECT REVISION <<< "{query}"

# Go to project folder
cd ~/Sites/$PROJECT

# run Dandelion
RESPONSE=$(dandelion deploy $REVISION)

# Notification
echo $RESPONSE

I'm loading the bash_profle because without it, it won't work as a "run script", as a terminal command it would run without it.

This is due the missing enviroment variables in the "run script" part.

 

The other commands are really basics.

 

Is there a better way to handle this enviroment stuff? As I run often in this situation with other workflows I've written.

Also I'm missing in Alfred something like a settings dialog for workflows.

 

Cheers Ralf

 

PS: Forgot to say, it works perfectly for me, but I still have the feeling that it could be better…

Edited by Horttcore
Link to comment

Is there a better way to handle this enviroment stuff? As I run often in this situation with other workflows I've written.

There is not, unfortunately. Workflow authors often work around it the same way you did. Other popular solutions include explicitly setting your PATH, or using the full path of the app when calling it. Neither of those is inherently better than yours — they still need an extra line of code, and will only work with certainty in your system.

 

Also I'm missing in Alfred something like a settings dialog for workflows.

Another example of something you have to work around. Similarly to the above, there isn’t a standard for this — it depends very much on the workflow, the author, and even the framework you’re using (if any). Solutions include having an extra Alfred command where you set your options inline, or informing users to open a specific file inside the workflow and edit it manually. Even then there is no real standard — how (and in what format) you save these and how you read them back, is up to you. There are some recommendations regarding where to save these files, though — volatile setting should go in ~/Library/Caches/com.runningwithcrayons.Alfred-2/Workflow Data/, and non-volatile settings in ~/Library/Application Support/Alfred 2/Workflow Data/.

Link to comment

I'm loading the bash_profle because without it, it won't work as a "run script", as a terminal command it would run without it.

This is due the missing enviroment variables in the "run script" part.

 

This is something that will bite you whenever you run a script via an OS X app and not directly in a shell. All apps (and by extension anything they launch) use launchd's environment (as that's the root process).

 

In the case of a workflow, I'd recommend against sourcing your own ~/.bashrc (or whatever) unless you're sure you're never going to want to distribute the workflow. Even if it's, say, something that's only for developers who are guaranteed to have the environmental variable set, they might use zsh, not bash…

 

There are ways to get around some of the limitations (such as LANG and LC_* vars not being set or set to "C") by getting OS X's environmental settings with defaults. For example, you can get the system language(s) with: 

defaults read -g AppleLanguages

 In other cases, you just have to ask the workflow user to provide the necessary information :(

Edited by deanishe
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...