Tsutomu
Tsutomu

Reputation: 5148

How to give a description to an alias defined in mix.exs?

When I define an alias in the mix.exs and run mix help, it just shows its description as "Alias defined in mix.exs".

Suppose, for example, I have this mix.exs:

  defp aliases do
    [
      play: "run --no-halt"
    ]
  end

Then, the mix help command displays task list like this:

...
mix local.rebar       # Installs Rebar locally
mix new               # Creates a new Elixir project
mix play              # Alias defined in mix.exs
mix profile.cprof     # Profiles the given file or expression with cprof
mix profile.eprof     # Profiles the given file or expression with eprof
...

How can I give a description to the play task?

Upvotes: 2

Views: 356

Answers (1)

sdc
sdc

Reputation: 3041

The output from mix help comes from the @shortdoc attribute in a custom mix task

defmodule Mix.Tasks.Play do
  use Mix.Task
  @shortdoc "run with --no-halt"

  @impl Mix.Task
  def run(_) do
    Mix.Task.run("run", ["--no-halt"])
  end
end
mix help | grep "mix play"
mix play                  # run with --no-halt

I don't think there is a way to add help docs for aliases.

Upvotes: 6

Related Questions