+ def shell_yes?(message) do
+ if mix_shell?(),
+ do: Mix.shell().yes?("Continue?"),
+ else: shell_prompt(message, "Continue?") in ~w(Yn Y y)
+ end
+
+ def shell_info(message) do
+ if mix_shell?(),
+ do: Mix.shell().info(message),
+ else: IO.puts(message)
+ end
+
+ def shell_error(message) do
+ if mix_shell?(),
+ do: Mix.shell().error(message),
+ else: IO.puts(:stderr, message)
+ end
+
+ @doc "Performs a safe check whether `Mix.shell/0` is available (does not raise if Mix is not loaded)"
+ def mix_shell?, do: :erlang.function_exported(Mix, :shell, 0)
+