magefile / mage

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

feat: Nested Namespaces #433

Open 56KBs opened 2 years ago

56KBs commented 2 years ago

Provide the ability to nest namespaces by defining a type that transitively is a mg.Namespace.

Namespaces can have functions named the same as a sub-namespace.

An example magefile:

type Docker mg.Namespace

func (Docker) Build() { fmt.Println("docker:build") }

type Developer Docker

func (Developer) Build() { fmt.Println("docker:developer:build") }

type CI Docker

func (CI) Build() { fmt.Println("docker:ci:build") }

Results in the following:

Targets:
  docker:build              
  docker:ci:build           
  docker:developer:build    

Closes #152

This does not implement nested/transitive imports, only namespaces.

Penthious commented 1 year ago

Any traction on this? Would be a really nice feature to add in for us. Would allow us to do something like mage staging:go:build or mage production:pulumi:apply

rzajac commented 1 year ago

Any chance this can be merged?