Skip to content

Commit

Permalink
internal/executor: Remove unused interface funcs
Browse files Browse the repository at this point in the history
  • Loading branch information
splaspood committed Aug 7, 2024
1 parent 60e5956 commit 4a10cd6
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 44 deletions.
42 changes: 0 additions & 42 deletions internal/executor/executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,9 @@ type Executor interface {
ExecWithContext(context.Context) (*Result, error)
SetArgs([]string)
SetEnv([]string)
SetQuiet()
SetVerbose()
GetCmd() string
DisableBinCheck()
SetStdin(io.Reader)
CmdPath() string
CheckExecutable() error
// for tests
SetStdout([]byte)
SetStderr([]byte)
SetExitCode(int)
}

func NewExecutor(cmd string) Executor {
Expand Down Expand Up @@ -58,12 +50,6 @@ func (e *Execute) GetCmd() string {
return strings.Join(cmd, " ")
}

// CmdPath returns the absolute path to the executable
// this means the caller should not have disabled CheckBin.
func (e *Execute) CmdPath() string {
return e.Cmd
}

// SetArgs sets the command args
func (e *Execute) SetArgs(a []string) {
e.Args = a
Expand All @@ -74,38 +60,10 @@ func (e *Execute) SetEnv(env []string) {
e.Env = env
}

// SetQuiet lowers the verbosity
func (e *Execute) SetQuiet() {
e.Quiet = true
}

// SetVerbose does whats it says
func (e *Execute) SetVerbose() {
e.Quiet = false
}

// SetStdin sets the reader to the command stdin
func (e *Execute) SetStdin(r io.Reader) {
e.Stdin = r
}

// DisableBinCheck disables validating the binary exists and is executable
func (e *Execute) DisableBinCheck() {
e.CheckBin = false
}

// SetStdout doesn't do much, is around for tests
func (e *Execute) SetStdout(_ []byte) {
}

// SetStderr doesn't do much, is around for tests
func (e *Execute) SetStderr(_ []byte) {
}

// SetExitCode doesn't do much, is around for tests
func (e *Execute) SetExitCode(_ int) {
}

// ExecWithContext executes the command and returns the Result object
func (e *Execute) ExecWithContext(ctx context.Context) (result *Result, err error) {
if e.CheckBin {
Expand Down
1 change: 0 additions & 1 deletion internal/executor/executor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ func Test_Stdin(t *testing.T) {
e.Cmd = "grep"
e.Args = []string{"hello"}
e.Stdin = bytes.NewReader([]byte("hello"))
e.SetQuiet()

result, err := e.ExecWithContext(context.Background())
if err != nil {
Expand Down
1 change: 0 additions & 1 deletion internal/sum/sum.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ func New(host, user, pass string, opts ...Option) (*Sum, error) {

e := ex.NewExecutor(sum.SumPath)
e.SetEnv([]string{"LC_ALL=C.UTF-8"})
// e.SetQuiet()
sum.Executor = e

return sum, nil
Expand Down

0 comments on commit 4a10cd6

Please sign in to comment.