diff --git a/command_darwin.go b/command_darwin.go index f039f7b..35e6355 100644 --- a/command_darwin.go +++ b/command_darwin.go @@ -10,6 +10,14 @@ func createBaseCommand(c *Command) *exec.Cmd { return cmd } +// WithUser allows the command to be run as a different +// user. +// +// Example: +// +// cred := syscall.Credential{Uid: 1000, Gid: 1000} +// c := NewCommand("echo hello", cred) +// c.Execute() func WithUser(credential syscall.Credential) func(c *Command) { return func(c *Command) { c.baseCommand.SysProcAttr = &syscall.SysProcAttr{ diff --git a/command_linux.go b/command_linux.go index f039f7b..35e6355 100644 --- a/command_linux.go +++ b/command_linux.go @@ -10,6 +10,14 @@ func createBaseCommand(c *Command) *exec.Cmd { return cmd } +// WithUser allows the command to be run as a different +// user. +// +// Example: +// +// cred := syscall.Credential{Uid: 1000, Gid: 1000} +// c := NewCommand("echo hello", cred) +// c.Execute() func WithUser(credential syscall.Credential) func(c *Command) { return func(c *Command) { c.baseCommand.SysProcAttr = &syscall.SysProcAttr{ diff --git a/command_windows.go b/command_windows.go index fce4a27..45b8c6f 100644 --- a/command_windows.go +++ b/command_windows.go @@ -10,6 +10,14 @@ func createBaseCommand(c *Command) *exec.Cmd { return cmd } +// WithUser allows the command to be run as a different +// user. +// +// Example: +// +// token := syscall.Token(handle) +// c := NewCommand("echo hello", token) +// c.Execute() func WithUser(token syscall.Token) func(c *Command) { return func(c *Command) { c.baseCommand.SysProcAttr = &syscall.SysProcAttr{