aboutsummaryrefslogtreecommitdiff
path: root/lib/mix
diff options
context:
space:
mode:
authoreal <eal@waifu.club>2018-12-07 06:48:39 +0000
committereal <eal@waifu.club>2018-12-07 06:48:39 +0000
commitc88db2c1b115ebca000bae6bb259d03f9d9aa1f7 (patch)
tree57a32ecca2c76649863d364ba3d06c7b771277a3 /lib/mix
parent220de2400238402229ac320cc3e7ccc9738de5ce (diff)
parent08e10a70ec8752b30010389c0f5e14105fc58c3e (diff)
downloadpleroma-c88db2c1b115ebca000bae6bb259d03f9d9aa1f7.tar.gz
Merge branch 'fix/add-common.ex' into 'develop'
add common.ex See merge request pleroma/pleroma!511
Diffstat (limited to 'lib/mix')
-rw-r--r--lib/mix/tasks/pleroma/common.ex24
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/mix/tasks/pleroma/common.ex b/lib/mix/tasks/pleroma/common.ex
new file mode 100644
index 000000000..06893af05
--- /dev/null
+++ b/lib/mix/tasks/pleroma/common.ex
@@ -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