Yesterday I wrote a little bit of code and learned a bit more about the current state of OS X automation. Today I took another small step on my personal automation, itch-finding and itch-scratching journey.
Like many second steps, it was even simpler than the first. I created a service which takes the selected text, fetches the URL of the currently active page in Safari and creates a Markdown link of the selection.
Here is the gist, copious documentation included.
So far so good, all I wondered was how I would test it without saving, restarting applications and flailing wildly. Happily, Automator told me when I tried clicking the run button. Politely, it informed me that the service would not be able to get any input inside Automator, but that I could add an action to simulate this. And I could, dragging in "Get specified text" at the start of my workflow let me specify input for my function. There was even a "View results" action to clearly display output afterward.
The one remaining question, I guess, is why those two actions are not automatically active (when needed) inside Automator and then removed in the finished workflow. The dialog which told me about "Get specified text" was careful in reminding me to remove the action after using it, but it sure seems like a thing a decent computer could manage for me.
If you want to write scripts for inclusion in Automator workflows, it seems to me you should be doing your writing in Automator, rather than in Script editor.
What I would really want, though, is to be able to write in Safari and have access to some real developer tools. Auto completion, breakpoints, a REPL, you name it. Surely there is a way of simulating the environment of a script in there too and let us have the good tools for everything?