]> ruderich.org/simon Gitweb - safcm/safcm.git/blob - remote/run/runner.go
Use SPDX license identifiers
[safcm/safcm.git] / remote / run / runner.go
1 // Interface to run commands
2
3 // SPDX-License-Identifier: GPL-3.0-or-later
4 // Copyright (C) 2021-2024  Simon Ruderich
5
6 package run
7
8 import (
9         "os/exec"
10 )
11
12 // Runner abstracts running commands to permit testing.
13 type Runner interface {
14         Run(*exec.Cmd) error
15         CombinedOutput(*exec.Cmd) ([]byte, error)
16 }
17
18 // ExecRunner implements Runner by calling the corresponding function from
19 // exec.Cmd.
20 type ExecRunner struct {
21 }
22
23 func (r ExecRunner) Run(cmd *exec.Cmd) error {
24         return cmd.Run()
25 }
26 func (r ExecRunner) CombinedOutput(cmd *exec.Cmd) ([]byte, error) {
27         return cmd.CombinedOutput()
28 }