Is there a way to append the output from two differents commands?
for example:
self.window.run_command("exec", {"cmd": cmd1})
self.window.run_command("exec", {"cmd": cmd2})
and the output in the console shows the info from cmd1
and cmd2
Is there a way to append the output from two differents commands?
for example:
self.window.run_command("exec", {"cmd": cmd1})
self.window.run_command("exec", {"cmd": cmd2})
and the output in the console shows the info from cmd1
and cmd2
You could use shell functions to make ST execute both programs in one “exec” call.
self.window.run_commnd("exec", {"shell_cmd": "{} & {}".format(cmd1, cmd2)})
Thanks @FichteFoll that was exactly what I want!
Other question, maybe you can help me, do you know how can I get the output text and edit it? and at the same time get the return code of the execution?
At that point, you should start looking into working with subprocess.Popen
directly.
The exec
command is useful only if you intend the user to see the external program’s output but do not intend to do anything with it yourself.
When you want to do work with the external program’s output, you need to call subprocess.Popen
(or another function in the subprocess
module) and take care of displaying the output to the user if you want to. The exec
command source code should get you started on how to work with output panels. You can investigate that in Default/exec.py
(using the PackageResourceViewer package).