User defined Mix Tasks

Hi Guys!

Is there a way to define user Mix tasks, just like mix phx.new without the hassle of creating a project, packaging and installing, i.e. using exs ?

What I want to do is create a set of tasks that generate initial project files for me, such as vscode tasks, editorconfig file etc. So I could just do on any folder mix vscode.init and have the files generated to me.

The problem is that I don’t know if is possible or where to put the exs files under the .mix directory on my home

One thing you might look at is the project template tool created by @pragdave:

https://pragdave.me/blog/2017/04/18/elixir-project-generator.html

If you want to have a mix task that lives outside of a project, then I think what you do is create an archive (see e.g. https://hashrocket.com/blog/posts/create-and-publish-your-own-elixir-mix-archives) and put your mix tasks in it.

2 Likes