magefile / mage

a Make/rake-like dev tool using Go
https://magefile.org
Apache License 2.0
4.01k stars 250 forks source link

Added working directory and context support. #444

Open hamzaelsaawy opened 1 year ago

hamzaelsaawy commented 1 year ago

This PR is an attempt to solve https://github.com/magefile/mage/issues/213

Added sh.Command struct to mirror exec.Cmd and allow configuring sh.Exec options, instead of adding a new function that can change the working directory.

A single configuration struct was chosen instead of options since the struct aggregates all configuration options together.

Added current sh.Exec parameters to sh.Command as fields, and mimicked current behavior.

Moved sh.run functionality to sh.(*Command).run, and updated sh.Exec to use sh.Command.Exec.

Added WorkingDir field to change the command's working directory.