Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions pkg/board/remote/adb/adb.go
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ func (a *ADBConnection) Remove(path string) error {

type ADBCommand struct {
cmd *paths.Process
err error
}

func (a *ADBConnection) GetCmd(cmd string, args ...string) remote.Cmder {
Expand All @@ -243,19 +244,31 @@ func (a *ADBConnection) GetCmd(cmd string, args ...string) remote.Cmder {
cmds = append(cmds, args...)
}

command, _ := paths.NewProcess(nil, cmds...)
return &ADBCommand{cmd: command}
command, err := paths.NewProcess(nil, cmds...)
return &ADBCommand{cmd: command, err: err}
}

func (a *ADBCommand) Run(ctx context.Context) error {
if a.err != nil {
return fmt.Errorf("failed to create command: %w", a.err)
}

return a.cmd.RunWithinContext(ctx)
}

func (a *ADBCommand) Output(ctx context.Context) ([]byte, error) {
if a.err != nil {
return nil, fmt.Errorf("failed to create command: %w", a.err)
}

return a.cmd.RunAndCaptureCombinedOutput(ctx)
}

func (a *ADBCommand) Interactive() (io.WriteCloser, io.Reader, io.Reader, remote.Closer, error) {
if a.err != nil {
return nil, nil, nil, nil, fmt.Errorf("failed to create command: %w", a.err)
}

stdin, err := a.cmd.StdinPipe()
if err != nil {
return nil, nil, nil, nil, fmt.Errorf("failed to get stdin pipe: %w", err)
Expand Down