mage icon indicating copy to clipboard operation
mage copied to clipboard

Enhancement: glob targets

Open flowchartsman opened this issue 1 year ago • 0 comments

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)

flowchartsman avatar Dec 27 '22 23:12 flowchartsman