Merge branch 'fix/mix-task-yn-prompt' into 'develop'

Remove Mix.Pleroma.shell_yes?/1

See merge request pleroma/pleroma!3179
This commit is contained in:
feld 2020-12-04 18:17:35 +00:00
commit b3ee618e0d
3 changed files with 5 additions and 11 deletions

View file

@ -98,12 +98,6 @@ def shell_prompt(prompt, defval \\ nil, defname \\ nil) do
end end
end end
def shell_yes?(message) do
if mix_shell?(),
do: Mix.shell().yes?("Continue?"),
else: shell_prompt(message, "Continue?") in ~w(Yn Y y)
end
def shell_info(message) do def shell_info(message) do
if mix_shell?(), if mix_shell?(),
do: Mix.shell().info(message), do: Mix.shell().info(message),

View file

@ -60,7 +60,7 @@ def run(["new", nickname, email | rest]) do
- admin: #{if(admin?, do: "true", else: "false")} - admin: #{if(admin?, do: "true", else: "false")}
""") """)
proceed? = assume_yes? or shell_yes?("Continue?") proceed? = assume_yes? or shell_prompt("Continue?", "n") in ~w(Yn Y y)
if proceed? do if proceed? do
start_pleroma() start_pleroma()

View file

@ -36,7 +36,7 @@ test "user is created" do
unsaved = build(:user) unsaved = build(:user)
# prepare to answer yes # prepare to answer yes
send(self(), {:mix_shell_input, :yes?, true}) send(self(), {:mix_shell_input, :prompt, "Y"})
Mix.Tasks.Pleroma.User.run([ Mix.Tasks.Pleroma.User.run([
"new", "new",
@ -55,7 +55,7 @@ test "user is created" do
assert_received {:mix_shell, :info, [message]} assert_received {:mix_shell, :info, [message]}
assert message =~ "user will be created" assert message =~ "user will be created"
assert_received {:mix_shell, :yes?, [message]} assert_received {:mix_shell, :prompt, [message]}
assert message =~ "Continue" assert message =~ "Continue"
assert_received {:mix_shell, :info, [message]} assert_received {:mix_shell, :info, [message]}
@ -73,14 +73,14 @@ test "user is not created" do
unsaved = build(:user) unsaved = build(:user)
# prepare to answer no # prepare to answer no
send(self(), {:mix_shell_input, :yes?, false}) send(self(), {:mix_shell_input, :prompt, "N"})
Mix.Tasks.Pleroma.User.run(["new", unsaved.nickname, unsaved.email]) Mix.Tasks.Pleroma.User.run(["new", unsaved.nickname, unsaved.email])
assert_received {:mix_shell, :info, [message]} assert_received {:mix_shell, :info, [message]}
assert message =~ "user will be created" assert message =~ "user will be created"
assert_received {:mix_shell, :yes?, [message]} assert_received {:mix_shell, :prompt, [message]}
assert message =~ "Continue" assert message =~ "Continue"
assert_received {:mix_shell, :info, [message]} assert_received {:mix_shell, :info, [message]}