ExecProcess
Runs the given*exec.Cmd in a blocking fashion, effectively pausing the Program while the command is running. After the *exec.Cmd exits the Program resumes. It’s useful for spawning other interactive applications such as editors and shells from within a Program.
The
*exec.Cmd to execute. This is a standard Go os/exec.Cmd pointer.A callback function that receives any error that occurred during execution and returns a message. Can be
nil if you don’t care about errors.Returns
Returns aCmd that, when executed, runs the external process and blocks until it completes.
Examples
Opening an Editor
Running a Shell
Ignoring Errors
If you don’t care about errors, you can simply passnil as the callback:
ExecCallback
A callback function type used when executing an*exec.Command to return a message with an error, which may or may not be nil.
The error that occurred during execution, or
nil if execution was successful.Returns
Returns aMsg that will be sent to your program’s Update function.
Example
ExecCommand
An interface that can be implemented to execute things in a blocking fashion in the current terminal.*exec.Cmd when wrapped by ExecProcess. You typically don’t need to implement this interface yourself unless you’re creating custom execution behavior.
Important Notes
Blocking Behavior
ExecProcess blocks the entire Bubble Tea program while the command is running. The program will:
- Release control of the terminal
- Run the external command
- Wait for it to complete
- Restore terminal control
- Send the callback message to
Update
Interactive vs Non-Interactive
For non-interactive I/O, you should use a regulartea.Cmd instead of ExecProcess. Use ExecProcess only when you need:
- User interaction with the external program (editors, shells, etc.)
- Full terminal control by the external program
- Blocking behavior