openterm
openterm copied to clipboard
invoke OpenTerm through x-callback-url
I think it would be useful to be able to run commands in OpenTerm from other apps through x-callback-url, which is sort of the reverse of issue #26.
Imagine something along the lines of:
openterm://x-callback-url/run?command=grep%20find&input=stuff%20%on%20stdin%20to%find
&x-success=...&x-error=...
The command
parameter is the command that is executed, while input
is passed to stdin
. Depending on the status code of the command either x-success
or x-error
callbacks are done with the text result from either stdout
or stderr
.
Since commands can do all sorts of things, it would probably be best to have a key
parameter with a random password like Drafts and Working Copy have, such that users are not tricked into running malicious commands.
How would you feel about such a feature?
Anything you would like me to consider?
Great idea! I also like the key
parameter idea.
This in combination with Workflow would open so many possibilities.
I have a feeling changes are coming to how commands are processed to facilitate script files and such and that it would be better to wait before implementing invoking commands through x-callback-url.
My strategy will pretty much be:
- parse x-callback-url and write the contents of the
input
parameter to a temporary file. - invoke the command where stdin is redirected from the temporary file and such that stdout and stderr are redirected to two other temporary files.
- depending on status code of command, the x-success or x-error callback is made with content of the respective temporary file.
Depending on how scripting ends up working, the command might also be put in a temporary script file if this could make redirection cleaner for composite commands.
I am open to using a different strategy. I'm writing this up to get feedback before doing a lot of work.