aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRin Toshaka <rinpatch@sdf.org>2018-12-07 06:12:39 +0100
committerRin Toshaka <rinpatch@sdf.org>2018-12-07 06:12:39 +0100
commit1d11c4cf11e27992c6b79731015456a954307e8f (patch)
treed03bba0a4bd1646c0d357c9cf0a87de2166f47a2 /lib
parentf5726a2e12102fd0742a767e508fcd4ac9406a09 (diff)
downloadpleroma-1d11c4cf11e27992c6b79731015456a954307e8f.tar.gz
add common.ex
Diffstat (limited to 'lib')
-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..2e246c4b5
--- /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, def \\ nil, defname \\ nil) do
+ Keyword.get(options, opt) ||
+ case Mix.shell().prompt("#{prompt} [#{defname || def}]") do
+ "\n" ->
+ case def do
+ nil -> get_option(options, opt, prompt, def)
+ def -> def
+ end
+
+ opt ->
+ opt |> String.trim()
+ end
+ end
+
+ def escape_sh_path(path) do
+ ~S(') <> String.replace(path, ~S('), ~S(\')) <> ~S(')
+ end
+end