magefile / mage

a Make/rake-like dev tool using Go

Home Page:https://magefile.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Enhancement: Variadic support in mg.F

perj opened this issue · comments

Describe the feature
I would like mg.F to support variadic functions.

What problem does this feature address?
The main use case would be to pass sh.Run to it, as such: mg.F(sh.Run, "go", "test", "./...")
I think this should be possible with some work. mg.F(sh.Run, "go", []string{"test", "./..."}) would also be ok, or another function instead of mg.F.

Right now there's a lot of single-line functions that need to be added that are then passed to mg.Deps. As pointed out in #400, it's possible to use inline function literals for this, but those are also quite verbose. Also they might run the same command multiple times, as the arguments and actual function are not part of the deps check for those literals.

Having sh.Run directly in mg.Deps improve readability and simplifies the magefile writing.

Additional context
This occurred to me during the discussion in #400 where I had a different syntax for the same thing.