* Librarify mage
We can now use mage as a pure library, not just as a main function.
This makes test easier in many ways and opens up new ways to use mage.
* Helpers galore
This commit adds helper functions that should be commonly needed
by many magefiles. It includes command execution handlers as well
as error handlers.
This commit also removes the only two non-stdlib dependencies in
the codebase. Since mage will likely be vendored into a repo,
it would be nice to avoid cluttering the vendor directory with
dependencies that are only for the build script.
* * Added -init flag
* Altered magefile() to return on zero found so we can toggle creating when -init flag set
- Template for magefile.go added
- Generates a magefile.go in the CWD
* Made the example template more inspiring
* updated readme and added example of Default target
* * use os functions instead of dropping to shell comands as appropriate
* order of imports is alpha
* added note on Default for behaviour if not set
* added -init to flags section of readme
This change adds the mainfile template to the list of things we
hash to create the compiled binary name. This ensures that we
don't have to remember to bump the mageVer when we change the
template, it'll just always auto-update. mageVer only needs
to change if there's processing that will produce different output
from the template without the template actually changing
fixes#13
The bug was that non-stdlib imports were failing to be found by the parser.
The problem is that the default importer only imports from compiled files. But we specifically want to import from source files. For go 1.9 this is easy, go/importer has an importer.For that takes "source". However, previous to go 1.9, this doesn't exist. To keep the code working in previous versions, we just grab the code from 1.9's srcimporter and include it in the build, and then conditionally compile in that code if we're not running on go 1.9 or greater (if we are running on go 1.9, we can use the stdlib version, which is better because it'll get fixes etc automatically).
Also added a bunch of tests to ensure that this code won't break again without a test failing.
This code creates a new library 'mg' that lives under the mage
repo, which contains a function, Deps, that lets a function
declare it has dependencies on other functions. These functions
will be run in parallel, and may have their own dependencies.