Current section

Files

Jump to
doex lib doex cli shell.ex
Raw

lib/doex/cli/shell.ex

defmodule Doex.Cli.Shell do
def cmd("doex") do
if has_mix?() do
"mix doex"
else
"doex"
end
end
def cmd(raw_cmd) do
if has_mix?() do
String.replace(raw_cmd, "doex ", "mix doex.")
else
raw_cmd
end
end
def info(msg) do
if has_mix?() do
Mix.shell.info(msg)
else
IO.puts(msg)
end
end
def error(msg) do
if has_mix?() do
Mix.shell.error(msg)
else
IO.puts(msg)
end
end
def raise(msg) do
if has_mix?() do
Mix.raise(msg)
else
Kernel.raise(msg)
end
end
def newline, do: info ""
defp has_mix?, do: function_exported?(Mix, :shell, 1)
end