简体   繁体   中英

How do I set the default Elixir mix task

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 be the default, so it is executed when I run mix without a task?

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

def project do
  [default_task: "run"]
end

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM