简体   繁体   中英

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?

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.

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