Packages
exrm
1.0.8
1.0.8
1.0.6
1.0.5
1.0.4
1.0.3
1.0.2
1.0.1
1.0.0
1.0.0-rc8
1.0.0-rc7
1.0.0-rc6
1.0.0-rc5
1.0.0-rc4
1.0.0-rc3
0.19.9
0.19.8
0.19.7
0.19.6
0.19.5
0.19.4
0.19.3
0.19.2
0.19.1
0.19.0
0.18.8
0.18.7
0.18.6
0.18.5
0.18.4
0.18.3
0.18.2
0.18.1
0.18.0
0.17.3
0.17.2
0.17.1
0.17.0
0.16.0
0.15.3
0.15.2
0.15.1
0.15.0
0.14.17
0.14.16
0.14.15
0.14.14
0.14.13
0.14.12
0.14.11
0.14.10
0.14.9
0.14.8
0.14.7
0.14.6
0.14.5
0.14.3
0.14.2
0.14.1
0.14.0
0.12.12
0.12.11
0.12.10
0.12.9
0.12.8
0.12.7
0.12.6
0.12.5
0.12.4
0.11.3
0.11.2
0.11.1
0.11.0
0.10.3
0.10.1
0.10.0
0.9.2
0.9.1
0.8.1
0.8.0
0.7.3
0.7.2
0.7.1
0.7.0
0.6.15
0.6.14
0.6.13
0.6.12
0.6.11
0.6.10
0.6.9
0.6.8
0.6.7
0.6.6
0.6.5
0.6.4
0.6.3
0.6.2
0.6.1
0.6.0
0.5.0
0.4.7
Exrm, or Elixir Release Manager, provides mix tasks for building, upgrading, and controlling release packages for your application.
Current section
Files
Jump to
Current section
Files
lib/mix/tasks/release.plugins.ex
defmodule Mix.Tasks.Release.Plugins do
@moduledoc """
View information about active release plugins
## Examples
# View all active plugins
mix release.plugins
# View detailed info about a plugin, if available
mix release.plugins <plugin_name>
"""
@shortdoc "View information about active release plugins"
use Mix.Task
alias ReleaseManager.Utils.Logger
import ReleaseManager.Utils
def run(args) do
args |> parse_args |> do_run
end
defp do_run([action: :list]) do
case get_plugins do
[] -> IO.puts "No plugins found!"
plugins ->
for plugin <- plugins do
name = get_name(plugin)
shortdoc = get_shortdoc(plugin)
IO.puts String.ljust(name, 30) <> " # " <> shortdoc
end
end
end
defp do_run([action: :details, plugin: plugin]) do
plugin |> get_plugin |> display_plugin_long
end
defp get_plugins, do: ReleaseManager.Plugin.load_all
defp get_plugin(plugin) do
plugin_name = plugin |> String.downcase
result = ReleaseManager.Plugin.load_all |> Enum.find(fn module ->
module_name = module |> Atom.to_string |> String.downcase
given_name = get_name(module) |> String.downcase
cond do
module_name |> String.contains?(plugin_name) -> true
given_name |> String.contains?(plugin_name) -> true
true -> false
end
end)
case result do
nil ->
Logger.notice "No plugin by that name could be found!"
abort!
_ ->
result
end
end
defp display_plugin_long(plugin) do
name = get_name(plugin)
moduledoc = get_moduledoc(plugin)
if IO.ANSI.enabled? do
opts = [width: 80]
IO.ANSI.Docs.print_heading("#{name}", opts)
IO.ANSI.Docs.print(moduledoc, opts)
else
IO.puts "# #{name}\n"
IO.puts moduledoc
end
end
defp get_name(plugin) do
default = plugin |> Atom.to_string |> String.replace(~r/.*\./, "") |> String.downcase
get_plugin_info(plugin, :name, default)
end
defp get_shortdoc(plugin), do: get_plugin_info(plugin, :shortdoc, "No description available.")
defp get_moduledoc(plugin), do: get_plugin_info(plugin, :moduledoc, "No additional details available.")
defp get_plugin_info(plugin, type, default) when is_atom(plugin) and is_atom(type) do
case plugin.__info__(:attributes) |> List.keyfind(type, 0) do
{^type, [value]} -> value
nil -> default
end
end
defp parse_args(args) do
case OptionParser.parse(args) do
{_, [], _} -> [action: :list]
{_, [plugin], _} -> [action: :details, plugin: plugin]
{_, _, _} ->
Logger.error "Invalid arguments for `mix release.plugins`!"
abort!
end
end
end