How to set a default job for Elixir

If I have a mix.exs file something like:

 defmodule Mix.Tasks.My_task do use Mix.Task @shortdoc "Perform my task" def run(_) do IO.puts "Working" end end defmodule ElixirKoans.Mixfile do use Mix.Project def project do ... end 

I can happily run this with mix my_task .

How do I make my_task the default, so it runs when I run mix without a task?

+9
elixir mix
Sep 29 '13 at 0:05
source share
1 answer

It looks like you can define inside the project block (mix.exs) with default_task :

 def project do [default_task: "run"] end 

Additional information: https://github.com/elixir-lang/elixir/blob/f3f64cdba205253ca0bbc0ce6a5dddd500ffb48f/lib/mix/lib/mix/project.ex#L266-L280

+19
Sep 29 '13 at 5:47 on
source share



All Articles