fix 486: Add option --assume-yes to allow it to work non-interactive

This commit is contained in:
spctrl 2019-01-04 22:11:46 +01:00
parent 8e7da98b18
commit 4aa977d3b3

View File

@ -22,6 +22,7 @@ defmodule Mix.Tasks.Pleroma.User do
- `--password PASSWORD` - the user's password - `--password PASSWORD` - the user's password
- `--moderator`/`--no-moderator` - whether the user is a moderator - `--moderator`/`--no-moderator` - whether the user is a moderator
- `--admin`/`--no-admin` - whether the user is an admin - `--admin`/`--no-admin` - whether the user is an admin
- `-y`, `--assume-yes`/`--no-assume-yes` - whether to assume yes to all questions
## Generate an invite link. ## Generate an invite link.
@ -61,7 +62,11 @@ defmodule Mix.Tasks.Pleroma.User do
bio: :string, bio: :string,
password: :string, password: :string,
moderator: :boolean, moderator: :boolean,
admin: :boolean admin: :boolean,
assume_yes: :boolean
],
aliases: [
y: :assume_yes
] ]
) )
@ -79,6 +84,7 @@ defmodule Mix.Tasks.Pleroma.User do
moderator? = Keyword.get(options, :moderator, false) moderator? = Keyword.get(options, :moderator, false)
admin? = Keyword.get(options, :admin, false) admin? = Keyword.get(options, :admin, false)
assume_yes? = Keyword.get(options, :assume_yes, false)
Mix.shell().info(""" Mix.shell().info("""
A user will be created with the following information: A user will be created with the following information:
@ -93,7 +99,7 @@ defmodule Mix.Tasks.Pleroma.User do
- admin: #{if(admin?, do: "true", else: "false")} - admin: #{if(admin?, do: "true", else: "false")}
""") """)
proceed? = Mix.shell().yes?("Continue?") proceed? = assume_yes? or Mix.shell().yes?("Continue?")
unless not proceed? do unless not proceed? do
Common.start_pleroma() Common.start_pleroma()