Open moorereason opened 4 years ago
I like option 2 - give an option for kebab-cased targets. I think I would make this something you'd set in the magefile itself, like
const UseKebabTargets = true
that way it's standardized for everyone that uses that particular magefile, rather then being an environment variable, which would change behavior for each person (potentially screwing up other scripts and making each person have incompatible commands).
I was favoring option 2 as well.
Woul n't it be easier to allow the currently implemented namespaced targets to be called using a -
as well as using a :
? Then this problem would be solved more elegantly.
I going to give it a try.
Quick question: can't we support alias by default? like if we pass my-target
it first tries to run myTarget
and if not it fails? You can't declare func my-target() error {...}
in go so it makes sense, frictionless and retrocompatible to introduce aliasing? I can come up with a PR cc @anuraaga
I like @jcchavezs's idea of falling back to to non-kebab if it was passed in as it seems like it'd generally help without hurting.
Another idea is to recognize //export
comment on the function, this is the standard Go idiom for naming a function for use in an external system, often a C or WebAssembly library but magefile handling it would be quite natural too I think.
I came up with a PR for this https://github.com/magefile/mage/pull/441
I haven't seen this discussed before, so I wanted to open a discussion.
In my experience, most Makefiles that are not just cramming words together (e.g.
installhtml
,installps
) use kebab-cased targets (e.g.install-html
,install-ps
) instead of camelCased targets (e.g.installHtml
,installPs
). It would be helpful in migrating existing Makefiles and teams to mage if mage could more easily accommodate this pattern.I'm aware that aliases can help here, but mage Help output only shows the primary targets after running them through the
lowerFirst
template func.Two ideas: