Skip to content

Enhancement: Variadic support in mg.F #401

@perj

Description

@perj

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions