magefile / mage

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

improving the documentation - command line arguments #170

Open professor opened 5 years ago

professor commented 5 years ago

I'm new to go, and I was trying to find an example of a magefile that took in a command line option, e.g. 'mage command OPTION'

natefinch commented 5 years ago

Yeah, right now, that's not possible. The way to get around it is to set environment variables, so like

OPTION=foo mage command

There's a feature request for doing automatic arg detection: https://github.com/magefile/mage/issues/24

natefinch commented 5 years ago

There's an example in mage's magefile here: https://github.com/magefile/mage/blob/master/magefile.go#L55

But you're right, there should be docs about doing this, since it's a fairly common need.

kaimaera commented 4 months ago

Was trying to do the same and can across this issue.

I take it the situation hasn't changed?

I was wondering if something as simple as ignoring all command line arguments after the common "--" option and passing them directly to build targets would work? Haven't had a chance to look at the code, so just throwing it out there.