/
quiet.ex
59 lines (46 loc) · 1.48 KB
/
quiet.ex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
defmodule Mix.Shell.Quiet do
@moduledoc """
This is Mix's default shell when the `MIX_QUIET` environment
variable is set.
It's just like `Mix.Shell.IO`, but prints far less.
"""
@behaviour Mix.Shell
@doc """
Prints the current application if it
was not printed yet.
"""
defdelegate print_app, to: Mix.Shell.IO
@doc """
Prints nothing to the shell.
"""
def info(_message), do: :ok
@doc """
Prints the error to the shell followed by a newline.
"""
defdelegate error(message), to: Mix.Shell.IO
@doc """
Prints a message and prompts the user for input.
Input will be consumed until Enter is pressed.
"""
defdelegate prompt(message), to: Mix.Shell.IO
@doc """
Prints a message and asks the user to confirm if they
want to proceed. The user must type and submit one of
"y", "yes", "Y", "YES" or "Yes".
The user may also press Enter; this can be configured
to either accept or reject the prompt. The latter case
may be useful for a potentially dangerous operation that
should require explicit confirmation from the user.
## Options
* `:default` - (:yes or :no) if `:yes` pressing Enter
accepts the prompt; if `:no` pressing Enter rejects
the prompt instead. Defaults to `:yes`.
"""
defdelegate yes?(message, options \\ []), to: Mix.Shell.IO
@doc """
Executes the given command quietly without outputting anything.
"""
def cmd(command, opts \\ []) do
Mix.Shell.cmd(command, opts, fn data -> data end)
end
end