1
0
mirror of https://github.com/magefile/mage.git synced 2026-10-24 06:19:18 +03:00

41 Commits

Author SHA1 Message Date
Nate Finch
69e6f82473 Add support for optional arguments (#538)
add support for optional args
2026-03-07 19:51:18 -05:00
Nate Finch
78acbaf2e3 add the ability to call targets with float64 args (#525)
* add the ability to call targets with float64 args
2025-06-15 10:01:42 -04:00
na4ma4
0800736cf7 fix default selector ignoring Receiver and returning first matching function name (#509)
Co-authored-by: na4ma4 <na4ma4@users.noreply.github.com>
2024-11-24 15:53:19 +01:00
Horacio Duran
2385abb49a Correct test input code to support older go versions (#490)
Samples used for testing need to have build tags for new and old style:

```
//go:build tag
// +build tag
```

The particular problem here seems to be that 1.16 was actually importing the package referred in the `TestGoModules` test (`import "golang.org/x/text/unicode/norm"`) which, in the CI system's version lacks an old style go tag comment. Hence go complaining of a `//go:build` without a `// +build`. I made all files bi-tagged for consistency.
2023-11-18 18:05:41 +01:00
szTheory
2edffd1665 Comment typo: parse.go (#485) 2023-11-18 13:50:02 +01:00
Anuraag Agrawal
9f54e0f83e feat: support trailing line comment for mage:import (#480) 2023-09-12 11:24:18 -04:00
Peter McAtominey
a9206042d4 mage: cancel context on SIGINT (#313)
* mage: cancel context on SIGINT

On receiving an interrupt signal, mage cancels the context allowing the magefile
to perform any cleanup before exiting.

A second interrupt signal will kill the magefile process without delay.

The behaviour for a timeout remains unchanged (context is cancelled and the magefile
exits).

* mage: add cleanup timeout to cancel

Co-authored-by: Nate Finch <nate.finch@gmail.com>
2022-11-28 23:35:45 -05:00
Dan Kortschak
ae47c82d86 bring docs for use of directives up to date (#407)
* use no-space directive comment syntax in docs

* update build tag mentions in docs to use go:build over +build and make template conform
2022-03-17 20:42:21 -04:00
Horacio Duran
3504e09d7f Add magefiles directory support (#405)
* Use magefolder if no directory set and it exists.

If no directory was passed by the user as an explicit option and there is a folder named "magefolder" use that.

Workdir is kept as it is likely still "."

* Remove the default . for -d flag

Also correct os.Stat error checking to expect no error

* Add tests and test data for magefolder

* Rename magefolder and accept untagged files

Magefolder was renamed to magefiles
We now accept files that are not tagged too when using a magefiles directory

* Assume tagging when mix tagging is present

When using magefiles directory, if there are mixed tagging files assume tagging is used for mage files

* Update error format to %v

We support building for older go versions so error formatting should use %v

* sort outputs

* Accept mixed tagging in magefiles folder

When mixed tagging is found within a magefiles folder, opt to use all files

* little tweak to only do go list once when using magefiles directory

* Add magefiles directory information to the website

* Add a preference for mage files over directories

Add a temporary preference for mage files over magefiles directories and warn users this is a temporary functionality leading to a change where directory will be preferred.

Co-authored-by: Nate Finch <natefinch@github.com>
2022-03-16 12:23:18 -04:00
Viktor Voltaire
0873a9b4e1 feat: allow mage:import alias to be defined for multiple imports (#398) 2022-01-16 10:03:19 -05:00
Claudia Hardman
d9e2e4152d fix: deterministic compiled mainfile (#348)
* fix: determanistic compiled mainfile

sort template data so resulting mainfile is consistantly reproducible,
which is important to leverage build cache and results in a consistent
build id on output (given identical build parameters, e.g. ldflags,
output file name, etc.)

Result of `mage -compile ./mage_static && go tool buildid ./mage_static`
should now always be identical on repeated invocation.

Results in a probably imperceptible build time quickening, but solves a
minor peave of mine, and adds a test as protection from regression :)

* fix: poorly spelled test

Co-authored-by: Nate Finch <nate.finch@gmail.com>

* Update parse/parse.go

got caught out not using vim's spellcheck

Co-authored-by: Paul Burlumi <paul@burlumi.com>

* Update mage/main.go

got caught out not using vim's spellcheck

Co-authored-by: Paul Burlumi <paul@burlumi.com>

* fix spelling

Co-authored-by: Paul Burlumi <paul@burlumi.com>

Co-authored-by: Nate Finch <nate.finch@gmail.com>
Co-authored-by: Paul Burlumi <paul@burlumi.com>
Co-authored-by: Nate Finch <natefinch@github.com>
2021-09-27 00:33:47 -04:00
Nate Finch
aba395058b I guess arguments work now (#326)
* I guess arguments work now
* add mg.F
2020-12-28 23:58:26 -05:00
Nate Finch
0c7e3dee3e filter mageimport files (#281)
When calling mage import, we weren't prefiltering the list of go
files, so we'd get files with build tags and test files and such.
What we want is just the normal go files for building the library.
Using go list returns us that, so use that.
2020-01-13 23:53:11 -05:00
Nate Finch
aedfce64c1 fix one line imports as mage:imports (#204)
* fix one line imports as mage:imports

fixes #194
2018-12-11 16:18:45 -05:00
Nate Finch
edea463951 refactor alias/default parsing to support imported packages and namespaces (#203)
fixes #192
2018-12-11 14:22:28 -05:00
Nate Finch
0f9693c143 implement importing magefiles (#187)
implement mageimports
2018-10-10 23:44:18 -04:00
Nate Finch
a7a8e067f4 Support namespace functions with aliases and defaults (#183)
* support namespace funcs as aliases and defaults

fixes #181
2018-09-25 23:46:37 -04:00
Nate Finch
a9a0e40d28 Rely on GOCACHE rather than our own hashing mechanism (#168)
use gocache and add some debug timing logs
2018-09-18 23:05:49 -04:00
Nate Finch
c7b4ff9e70 add code so mg.Deps understands namespaces (#163)
* add code so mg.Deps understands namespaces

* unexport all the functype stuff
2018-09-15 23:32:08 -04:00
Nate Finch
276737a086 massive cleanup using go list (#153)
Simplify the code tremendously by using 'go list' instead of go/build, and remove the use of go/types to determine types (since we only care about a couple canonical types).
2018-09-10 18:26:41 -04:00
Nate Finch
bd5486e7f9 Add support for choosing what binary to run with mage (#146)
* add support for choose which go binary to run
* make the compiler configurable
* add a cli flag and update docs
* use go version as part of the binary hash
* add go version to what we display in mage -version
2018-09-06 21:23:00 -04:00
Nate Finch
01342b9221 Add debug flag (#143)
* add a bunch of debug logging
2018-08-31 08:45:43 -06:00
Nate Finch
253ba37b17 move checkdupes into parse (#138)
by putting checkdeps into parse, it gets checked by the parse tests
and it just a cleaner place to put it.
2018-08-26 10:12:01 -04:00
fazal
b853551298 Check for duplicates with namespace prefixed if any (#137)
Check for duplicates with namespace prefixed if any
2018-08-26 09:11:00 -04:00
Nate Finch
cfd05cd422 Output package docs with target list (#134)
* output package doc in mage -l

* add go 1.10 and 1.11 to test harness
2018-08-25 10:21:58 -04:00
Nate Finch
0b004e8e5c Fix panic in 126 (#127)
fix #126
2018-07-23 16:50:53 -04:00
Ryan Faerman
c807db8c20 Add namespace/subcommand support to Mage (#121)
Introduce an exported Namespace type in mg and use it to generate new targets.
2018-07-22 21:23:34 -04:00
Sunny
63768081a3 parse: sanitize function doc synopsis (#95)
This change adds `sanitizeSynopsis()` function to perform basic
sanitization on the synopsis. If synopsis begins with the function name, it
removes the function to avoid repeating words.
2017-12-29 07:42:55 -05:00
Marcin Białoń
898127b487 Support for aliases (#58) (#90) 2017-11-06 23:42:24 -05:00
James S
ab3ca2f6f8 Cleaned up use of mage/types package (#81)
* * Removed stale type declarations in parse.
* Updated parse and mg to make better use of types package.
* Added function to types package to test for valid function.
* Added function to to types package to wrap a valid FuncType as the
* most greedy of FuncType

* renamed IsFuncType and refactored to return error instead of bool. Made the return value of FuncTypeWrap more clear.

* removed unused type func declarations
2017-10-24 22:12:37 -04:00
Dragos Plesca
68180ebead Fix various typos (#80) 2017-10-22 09:21:27 -04:00
Nate Finch
be7943de50 Support multiple targets (#65)
* support multiple targets

* fix #66

* isolated list test

* add clean target to mage's magefile
2017-10-18 10:40:37 -04:00
James S
df367221b6 context for jobs (#32)
Allows for jobs that take and call with a context.  Closes #25
2017-10-17 23:57:04 -04:00
Nate Finch
2f974307b6 fix goroot (#74) 2017-10-16 23:49:30 -04:00
Nate Finch
8fa000d89f Helpers galore (#26)
* 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.
2017-10-02 22:22:21 -04:00
Nate Finch
d674cfaedd minor cleanup (#22)
* some minor cleanup
2017-09-29 18:24:23 -04:00
Nate Finch
8b6c4f7a9d fixes and a test (#15)
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.
2017-09-29 09:38:37 -04:00
Nate Finch
9dc8074005 implments configurable default targets (#7) 2017-09-27 00:05:03 -04:00
Nate Finch
d95f2a0d68 works now 2017-09-22 11:27:23 -04:00
Nate Finch
81ced8191d basically works now 2017-09-21 23:26:17 -04:00
Nate Finch
82d2f22ea3 parsing 2017-09-21 16:32:22 -04:00