magefile / mage

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

Enhancement: glob targets #450

Open flowchartsman opened 1 year ago

flowchartsman commented 1 year ago

Describe the feature I think it would be really nifty to be able to use mage in a make-like way with globs. Note: this is perhaps an alternative or enhancement to #340, which would also enable this sort of thing, albeit with a requisite target.

What problem does this feature address? I am writing a book using asciidoc, and I have targets for generating PDFs for pre-pub and editing. I would like to be able to generate ALL pdfs (target pdfs) or just one at a time mage manuscript/chapter07.pdf. Currently this isn't possible I don't think, however you could provide a way to mark a function (either exported or not) as accepting a certain glob. Maybe something like this:

func Pdfs() error {
  // get all files
  return pdf(allfiles...)
}

func pdf(fileTargets ...string) error {
  for _, ft := range fileTargets {
    //...
  }
}

mg.Globs(pdf, "manuscript/*.pdf)