Merge branch '394_user_tags' into 'develop'
[akkoma] / lib / mix / tasks / pleroma / common.ex
1 defmodule Mix.Tasks.Pleroma.Common do
2 @shortdoc "Common functions to be reused in mix tasks"
3 def start_pleroma do
4 Mix.Task.run("app.start")
5 end
6
7 def get_option(options, opt, prompt, defval \\ nil, defname \\ nil) do
8 Keyword.get(options, opt) ||
9 case Mix.shell().prompt("#{prompt} [#{defname || defval}]") do
10 "\n" ->
11 case defval do
12 nil -> get_option(options, opt, prompt, defval)
13 defval -> defval
14 end
15
16 opt ->
17 opt |> String.trim()
18 end
19 end
20
21 def escape_sh_path(path) do
22 ~S(') <> String.replace(path, ~S('), ~S(\')) <> ~S(')
23 end
24 end