Skip to content

Commit

Permalink
Add GetCmd method to expose the underlying exec.Cmd
Browse files Browse the repository at this point in the history
  • Loading branch information
bougou committed Aug 26, 2023
1 parent 49956be commit 08a3324
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
7 changes: 7 additions & 0 deletions rsync.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,13 @@ func (r Rsync) Run() error {
return r.cmd.Wait()
}

// GetCmd return the underlying exec.Cmd.
//
// The caller must call GetCmd method after calling Run.
func (r Rsync) GetCmd() *exec.Cmd {
return r.cmd
}

// NewRsync returns task with described options
func NewRsync(source, destination string, options RsyncOptions) *Rsync {
arguments := append(getArguments(options), source, destination)
Expand Down
8 changes: 8 additions & 0 deletions task.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"bytes"
"io"
"math"
"os/exec"
"strconv"
"strings"
"sync"
Expand Down Expand Up @@ -79,6 +80,13 @@ func (t *Task) Run() error {
return err
}

// GetCmd return the underlying exec.Cmd.
//
// The caller must call GetCmd method after calling Run.
func (r Task) GetCmd() *exec.Cmd {
return r.rsync.cmd
}

// NewTask returns new rsync task
func NewTask(source, destination string, rsyncOptions RsyncOptions) *Task {
// Force set required options
Expand Down

0 comments on commit 08a3324

Please sign in to comment.