Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancement: Variadic support in mg.F #401

Closed
perj opened this issue Jan 10, 2022 · 0 comments · Fixed by #402
Closed

Enhancement: Variadic support in mg.F #401

perj opened this issue Jan 10, 2022 · 0 comments · Fixed by #402

Comments

@perj
Copy link
Contributor

perj commented Jan 10, 2022

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.

perj added a commit to perj/mage that referenced this issue Jan 14, 2022
Allows to pass sh.Run to mg.F as such:

	mg.Deps(
		mg.F(sh.Run, "go", "test", "./..."),
	)

This improves the magefile by removing some of the one-liner functions
that you might end up with that are only used through mg.Deps.

Resolves magefile#401.
mirogta pushed a commit to perj/mage that referenced this issue Mar 23, 2022
Allows to pass sh.Run to mg.F as such:

	mg.Deps(
		mg.F(sh.Run, "go", "test", "./..."),
	)

This improves the magefile by removing some of the one-liner functions
that you might end up with that are only used through mg.Deps.

Resolves magefile#401.
natefinch pushed a commit that referenced this issue Mar 23, 2022
Allows to pass sh.Run to mg.F as such:

	mg.Deps(
		mg.F(sh.Run, "go", "test", "./..."),
	)

This improves the magefile by removing some of the one-liner functions
that you might end up with that are only used through mg.Deps.

Resolves #401.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant