Skip to content

Commit f24ea72

Browse files
committed
Improve documentation
1 parent a354933 commit f24ea72

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ A simple package to execute shell commands on linux, darwin and windows.
1515
## Usage
1616

1717
```go
18-
cmd := NewCommand("echo hello")
18+
cmd := cmd.NewCommand("echo hello")
1919

2020
err := cmd.Execute()
2121
if err != nil {
@@ -29,7 +29,7 @@ fmt.Println(cmd.Stderr())
2929
### Stream output to stderr and stdout
3030

3131
```go
32-
cmd := NewCommand("echo hello", cmd.WithStandardStreams)
32+
cmd := cmd.NewCommand("echo hello", cmd.WithStandardStreams)
3333
cmd.Execute()
3434
```
3535

@@ -58,4 +58,4 @@ make test
5858

5959
### ToDo
6060

61-
- os.Stdout and os.Stderr output access after execution
61+
- os.Stdout and os.Stderr output access after execution via `c.Stdout()` and `c.Stderr()`

command.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,14 @@ func NewCommand(cmd string, options ...func(*Command)) *Command {
6060
return c
6161
}
6262

63-
// WithStandardStreams creates a command which steams its output to the stderr and stdout streams of the operating system
63+
// WithStandardStreams is used as an option by the NewCommand constructor function and writes the output streams
64+
// to stderr and stdout of the operating system
65+
//
66+
// Example:
67+
//
68+
// c := cmd.NewCommand("echo hello", cmd.WithStandardStreams)
69+
// c.Execute()
70+
//
6471
func WithStandardStreams(c *Command) {
6572
c.StdoutWriter = os.Stdout
6673
c.StderrWriter = os.Stderr
@@ -77,7 +84,7 @@ func (c *Command) AddEnv(key string, value string) {
7784
c.Env = append(c.Env, fmt.Sprintf("%s=%s", key, value))
7885
}
7986

80-
// Removes the ${...} characters
87+
// Removes the ${...} characters at the beginng and end of the given string
8188
func removeEnvVarSyntax(v string) string {
8289
return v[2:(len(v) - 1)]
8390
}

0 commit comments

Comments
 (0)