forked from YokaiRick/akkoma
Merge branch 'fix/add-common.ex' into 'develop'
add common.ex See merge request pleroma/pleroma!511
This commit is contained in:
commit
c88db2c1b1
1 changed files with 24 additions and 0 deletions
24
lib/mix/tasks/pleroma/common.ex
Normal file
24
lib/mix/tasks/pleroma/common.ex
Normal file
|
@ -0,0 +1,24 @@
|
|||
defmodule Mix.Tasks.Pleroma.Common do
|
||||
@shortdoc "Common functions to be reused in mix tasks"
|
||||
def start_pleroma do
|
||||
Mix.Task.run("app.start")
|
||||
end
|
||||
|
||||
def get_option(options, opt, prompt, defval \\ nil, defname \\ nil) do
|
||||
Keyword.get(options, opt) ||
|
||||
case Mix.shell().prompt("#{prompt} [#{defname || defval}]") do
|
||||
"\n" ->
|
||||
case defval do
|
||||
nil -> get_option(options, opt, prompt, defval)
|
||||
defval -> defval
|
||||
end
|
||||
|
||||
opt ->
|
||||
opt |> String.trim()
|
||||
end
|
||||
end
|
||||
|
||||
def escape_sh_path(path) do
|
||||
~S(') <> String.replace(path, ~S('), ~S(\')) <> ~S(')
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue