【问题标题】:How to give a description to an alias defined in mix.exs?如何对 mix.exs 中定义的别名进行描述?
【发布时间】:2020-12-15 21:17:14
【问题描述】:

当我在mix.exs 中定义别名并运行mix help 时,它只是将其描述显示为“在 mix.exs 中定义的别名”。

假设,例如,我有这个mix.exs

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

然后,mix help 命令显示任务列表如下:

...
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
...

如何描述play 任务?

【问题讨论】:

    标签: elixir elixir-mix


    【解决方案1】:

    mix help 的输出来自自定义混合任务中的@shortdoc attribute

    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
    

    我认为没有办法为别名添加帮助文档。

    【讨论】:

      猜你喜欢
      • 2015-10-09
      • 2018-06-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-04-06
      相关资源
      最近更新 更多