I built a similar system once as a text editor plugin which let you execute selected Python code. The only way to pass arguments was to type or paste them. Pike’s interface provides a way to pass one argument via selection. You could allow an arbitrary number of selection-based arguments by having the user select the command then each of the arguments in turn. I haven’t tried it, but it doesn’t seem like it would be more cumbersome than typing arguments, and for one argument it would only involve reversing the order of actions in Pike’s system.
An important difference between the two systems was that mine operated in a single window, and commands returned information by modifying the selected text (either by appending to it or replacing it, at the choice of the user). One interesting way to use my extension to make programmatic edits was to open the file to be edited, go to the place where the edits need to happen, write a function that took some text and performed the edits on that text, and apply it to the text to be edited, wrapped in triple quotes. For code reuse, there was an automatically imported module (and of course you could just write ‘import whatever’, then select and execute it).