feat: add to string

This commit is contained in:
Kevin Franklin Kim 2024-04-30 18:53:03 +02:00
parent aa6a5bd64a
commit 489d6ba708
No known key found for this signature in database

View File

@ -97,6 +97,15 @@ func (c *Cmd) Stderr(w io.Writer) *Cmd {
return c
}
func (c *Cmd) String() string {
cmd := exec.Command(c.command[0], c.command[1:]...)
cmd.Env = append(os.Environ(), c.env...)
if c.cwd != "" {
cmd.Dir = c.cwd
}
return cmd.String()
}
func (c *Cmd) Run(ctx context.Context) (string, error) {
cmd := exec.CommandContext(ctx, c.command[0], c.command[1:]...)
cmd.Env = append(os.Environ(), c.env...)