mage icon indicating copy to clipboard operation
mage copied to clipboard

improving the documentation - command line arguments

Open professor opened this issue 7 years ago • 3 comments

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'

professor avatar Sep 19 '18 16:09 professor

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 avatar Sep 19 '18 17:09 natefinch

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.

natefinch avatar Sep 19 '18 18:09 natefinch

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.

kaimaera avatar Feb 18 '24 05:02 kaimaera