magefile / mage

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

Decouple `ParseAndRun` to allow customization of `Invocation` #442

Open cardil opened 1 year ago

cardil commented 1 year ago

Fixes #445

I'm introducing two functions Run and HandleParseError which allow users to customize the Invocation after it is parsed.

For example:

inv, cmd, err := Parse(stderr, stdout, args)
if retcode, doExit := HandleParseError(err, stderr); doExit {
  return retcode
}
inv.Stdin = stdin

# example customization
inv.WorkDir = ".." 
inv.Dir = "."

return Run(inv, cmd)