Tutorial by Examples

# lib/mix/tasks/mytask.ex defmodule Mix.Tasks.MyTask do use Mix.Task @shortdoc "A simple mix task" def run(_) do IO.puts "YO!" end end Compile and run: $ mix compile $ mix my_task "YO!"
In a basic implementation the task module must define a run/1 function that takes a list of arguments. E.g. def run(args) do ... end defmodule Mix.Tasks.Example_Task do use Mix.Task @shortdoc "Example_Task prints hello + its arguments" def run(args) do IO.puts "Hello ...
Elixir allows you to add aliases for your mix commands. Cool thing if you want to save yourself some typing. Open mix.exs in your Elixir project. First, add aliases/0 function to the keyword list that the project function returns. Adding () at the end of the aliases function will prevent compiler...
To list available mix tasks use: mix help To get help on a specific task use mix help task e.g.: mix help cmd

Page 1 of 1