1 # Pleroma: A lightweight social networking server
2 # Copyright © 2017-2018 Pleroma Authors <https://pleroma.social/>
3 # SPDX-License-Identifier: AGPL-3.0-only
5 defmodule Mix.Tasks.Pleroma.Common do
6 @doc "Common functions to be reused in mix tasks"
8 Application.put_env(:phoenix, :serve_endpoints, false, persistent: true)
9 {:ok, _} = Application.ensure_all_started(:pleroma)
12 def get_option(options, opt, prompt, defval \\ nil, defname \\ nil) do
13 Keyword.get(options, opt) ||
14 case Mix.shell().prompt("#{prompt} [#{defname || defval}]") do
17 nil -> get_option(options, opt, prompt, defval)
26 def escape_sh_path(path) do
27 ~S(') <> String.replace(path, ~S('), ~S(\')) <> ~S(')