Borg/cmd/main_test.go
google-labs-jules[bot] 03337982dd feat: Add compile and run commands for RUNC matrices
This commit introduces two new commands to the `borg` CLI:

- `borg compile`: Compiles a `Borgfile` into a "Terminal Isolation
  Matrix" (`.matrix` file). The `Borgfile` format is a simple text file
  with `ADD <src> <dest>` instructions.

- `borg run`: Executes a `.matrix` file using `runc`. The command
  unpacks the matrix into a temporary directory and then executes `runc
  run`.

Tests have been added for both commands, mocking the `runc` execution
to avoid environment dependencies.
2025-11-13 19:16:12 +00:00

25 lines
622 B
Go

package cmd
import (
"bytes"
"github.com/spf13/cobra"
)
// executeCommand is a helper function to execute a cobra command and return the output.
func executeCommand(root *cobra.Command, args ...string) (string, error) {
_, output, err := executeCommandC(root, args...)
return output, err
}
// executeCommandC is a helper function to execute a cobra command and return the output.
func executeCommandC(root *cobra.Command, args ...string) (*cobra.Command, string, error) {
buf := new(bytes.Buffer)
root.SetOut(buf)
root.SetErr(buf)
root.SetArgs(args)
c, err := root.ExecuteC()
return c, buf.String(), err
}