I had been using an extension in Alfred 1 that did conversions. I found it to be one of the most flexible extensions I found for doing conversions. It always knows what I mean. It is based on this java library: https://github.com/gnapse/metric The author of the java library originally posted the extension, but his blog is no longer online. I have been working on converting it to Alfred 2, though, and he said he didn't mind if I posted my workflow here for advice. It also does currency, but I discovered that sometime between when I began using the extension and now the provider of the currency info (OpenExchangeRates) had switched to requiring an App ID. So the versions of the workflow I'm going to post won't do currency conversion. However, I've found you can get a free App ID for personal use, so I've asked the author of the java library if he could add something that would let one pass an App ID so folks could sign up for their own. He said he would take a look. However that's not required for my question. The original extension simply called a brief bash script to pass your query to the java library and return a result to a notification. I first recreated that easily in an Alfred workflow: http://cl.ly/0J2f0A163y0Q
Now I'm trying to make it return results in the Alfred window. I've actually got a version of it working already, but it could use some polishing: http://cl.ly/013j3V1L0P0X
The trouble is how to handle the result when you are still typing. At first it returned errors in the Alfred window before your query was complete. Harmless, but ugly! The correct result will appear shortly after you finish typing. So far, I've managed to suppress the errors from going to stdout, so now it shows nothing for the second line if the library doesn't return a valid result. I haven't figured out how to put alternate text there, such as "Waiting for valid query" or some such.
So I'm looking for advice on what I can do to provide the nicest output experience. It seems like Alfred starts calling the script shortly after you start typing following the keyword and continues to call it repeatedly as the typed query changes.
As I see it, there are two options. Try to make a pause before the script kicks off, in hopes that you'd be done typing by the time it starts. However my concern is making it too long of a pause and slowing things down.
Second would be to try to return some friendlier text instead of the errors. You might still get a valid result before you are finished typing. For example typing "15 g in pounds" might return "15 grams = 15 grams" if the script processes after you type the g, but it does update to the desired result when you finish typing.
It's possible this is more of a bash question than an Alfred one, but I'd welcome any feedback/suggestions.