How to run Elixir CLI app via Mix Task during development?

I am creating a CLI app, which I intend to release as a binary using the great Bakeware project.

I am able to successfully create a binary and everything with the executable works great.

The binary is not practical for testing and development. I have created a Mix task to help in that regard:

defmodule Mix.Tasks.MyCLI do
  use Mix.Task

  def run(args) do"app.start")


Due to the requirements of Bakeware, I also have that module set up as the mod under application in my mix.exs:

  def application do
      extra_applications: [:logger],
      mod: {MyCLI, []}

When I run the CLI using my Mix Task, it seems to start two versions of the application at the same time. This does not happen via the executable.

What is the right way to set up my project for both development and release?

If you don’t want to start your the app in mix, you can change the line from:"app.start")


I tried that but if I don’t call app.start then the underlying OTP applications aren’t started and it just crashes. If I don’t call main from my Task, then nothing happens. If I do call it, it ends up being called twice.

Then you have to go back to app.start and make sure MyCLI.main() do not start anything.