Skip to content

Commit

Permalink
Merge pull request #99 from go-cmd/dn/v1.4.2
Browse files Browse the repository at this point in the history
Prepare v1.4.2: update docs, go.mod, some code comments
  • Loading branch information
daniel-nichter committed Jul 8, 2023
2 parents 745a5cf + ad53e14 commit 500562c
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 17 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Expand Up @@ -2,6 +2,10 @@

## v1.4

### v1.4.2 (2023-07-08)

* Added `Options.CombinedOutput` based on PR #76 by @jwomackgsa (issue #70)

### v1.4.1 (2022-03-27)

* Added `Options.LineBufferSize` based on PR #85 by @Crevil (issue #66)
Expand Down
24 changes: 11 additions & 13 deletions cmd.go
Expand Up @@ -147,16 +147,17 @@ type Options struct {
// See Cmd.Status for more info.
Buffered bool

// If CombinedOutput is true, STDOUT and STDERR are written to Status.Stdout ONLY similar to 2>&1.
// If CombinedOutput is used at the same time as Buffered, CombinedOutput will take preference.
// Status.StdErr will be empty. The caller can call Cmd.Status to read output at intervals.
// See Cmd.Status for more info.
// If CombinedOutput is true, STDOUT and STDERR are written only to Status.Stdout
// (similar to 2>&1 on Linux), and Status.StdErr will be empty. If CombinedOutput
// is used Buffered, CombinedOutput takes preference. CombinedOutput does not work
// with Streaming.
CombinedOutput bool

// If Streaming is true, Cmd.Stdout and Cmd.Stderr channels are created and
// STDOUT and STDERR output lines are written them in real time. This is
// faster and more efficient than polling Cmd.Status. The caller must read both
// streaming channels, else lines are dropped silently.
// streaming channels, else lines are dropped silently. Streaming does not work
// with CombinedOutput.
Streaming bool

// BeforeExec is a list of functions called immediately before starting
Expand All @@ -166,8 +167,7 @@ type Options struct {

// LineBufferSize sets the size of the OutputStream line buffer. The default
// value DEFAULT_LINE_BUFFER_SIZE is usually sufficient, but if
// ErrLineBufferOverflow errors occur, try increasing the size with this
// field.
// ErrLineBufferOverflow errors occur, try increasing the size with this field.
LineBufferSize uint
}

Expand Down Expand Up @@ -227,10 +227,9 @@ func NewCmdOptions(options Options, name string, args ...string) *Cmd {
return c
}

// Clone clones a Cmd. All the options are transferred,
// but the internal state of the original object is lost.
// Cmd is one-use only, so if you need to re-start a Cmd,
// you need to Clone it.
// Clone clones a Cmd. All the options are transferred, but the internal state
// of the original object is lost. Cmd is one-use only, so if you need to restart
// a Cmd, you need to Clone it.
func (c *Cmd) Clone() *Cmd {
clone := NewCmdOptions(
Options{
Expand Down Expand Up @@ -340,8 +339,7 @@ func (c *Cmd) Stop() error {
// consider using streaming output. When the command finishes, buffered output
// is complete and final.
//
// Status.Runtime is updated while the command is running and final when it
// finishes.
// Status.Runtime is updated while the command runs and is final when it finishes.
func (c *Cmd) Status() Status {
c.Lock()
defer c.Unlock()
Expand Down
4 changes: 2 additions & 2 deletions go.mod
@@ -1,5 +1,5 @@
module github.com/go-cmd/cmd

go 1.17
go 1.20

require github.com/go-test/deep v1.0.7
require github.com/go-test/deep v1.1.0
4 changes: 2 additions & 2 deletions go.sum
@@ -1,2 +1,2 @@
github.com/go-test/deep v1.0.7 h1:/VSMRlnY/JSyqxQUzQLKVMAskpY/NZKFA5j2P+0pP2M=
github.com/go-test/deep v1.0.7/go.mod h1:QV8Hv/iy04NyLBxAdO9njL0iVPN1S4d/A3NVv1V36o8=
github.com/go-test/deep v1.1.0 h1:WOcxcdHcvdgThNXjw0t76K42FXTU7HpNQWHpA2HHNlg=
github.com/go-test/deep v1.1.0/go.mod h1:5C2ZWiW0ErCdrYzpqxLbTX7MG14M9iiw8DgHncVwcsE=

0 comments on commit 500562c

Please sign in to comment.