Sublime Forum

How to run apps from a plugin

#1

I’ve recently installed the plugin Run Apps. After seeing the contents of the .sublime-commands it created I thought that I could do something similar in one of the plugins I’m messing with using sublime.run_command. So I tried to compose a call like this one below

self.view.run_command(cmd = "runapp", args = {"app": "C:\\my_program.exe", "args": ["C:\\my_argument_file.whatever", whatever_string_yielding_function(huhh)], "type": "file"})

in hope that it will run my_program and pass it the C:\\my_argument_file.whatever as the first argument followed by the result of the function whatever_string_yielding_function as the second argument. Alas, nothing happened, and I have no clue where I took the wrong turn. Any hints on this one?

0 Likes

#2

It’s a WindowCommand. Not TextCommand (view command) or ApplicationCommand.

1 Like

#3

Thank you very much @jfcherng , that brings me one step closer. Now I know that the call should have been toself.view.windows().run_command(blablabla) instead. That one even wants to work but fails with the following:

Save the buffer to a local file firstly

But that does not make much sense to me. The app that should be run has nothing to do with the contents of the buffer. Saving it would leave trash behind and would have to be saved over and over again, every time I close that tab and trigger the run_command from a new tab. Why would it need the buffer saved?

0 Likes

#4

Ask the plugin author. https://github.com/liuhewei/run-app-sublime/blob/8f333f0ef66e3b8692891e5708a464f67ace3195/runapp.py#L15

It’s fairly simple to execute an external program in Python.


Maybe you have other requirements I don’t know, but then ask the plugin author.

2 Likes

#5

That was really helpful, thank you very much @jfcherng!

1 Like