File tree Expand file tree Collapse file tree 2 files changed +12
-5
lines changed
Expand file tree Collapse file tree 2 files changed +12
-5
lines changed Original file line number Diff line number Diff 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
2020err := cmd.Execute ()
2121if 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 )
3333cmd.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() `
Original file line number Diff line number Diff 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+ //
6471func 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
8188func removeEnvVarSyntax (v string ) string {
8289 return v [2 :(len (v ) - 1 )]
8390}
You can’t perform that action at this time.
0 commit comments