@@ -19,7 +19,7 @@ defmodule Mix.Shell do
19
19
@ doc """
20
20
Executes the given command and returns its exit status.
21
21
22
- Shortcut for `cmd/2` with empty options.
22
+ Shortcut for `c: cmd/2` with empty options.
23
23
"""
24
24
@ callback cmd ( command :: String . t ( ) ) :: integer
25
25
@@ -28,6 +28,8 @@ defmodule Mix.Shell do
28
28
29
29
## Options
30
30
31
+ This callback should support the following options:
32
+
31
33
* `:print_app` - when `false`, does not print the app name
32
34
when the command outputs something
33
35
@@ -38,6 +40,9 @@ defmodule Mix.Shell do
38
40
39
41
* `:env` - environment options to the executed command
40
42
43
+ * `:cd` - (since v1.11.0) the directory to run the command in
44
+
45
+ All the built-in shells support these.
41
46
"""
42
47
@ callback cmd ( command :: String . t ( ) , options :: keyword ) :: integer
43
48
@@ -79,6 +84,7 @@ defmodule Mix.Shell do
79
84
goal is to avoid printing the application name
80
85
multiple times.
81
86
"""
87
+ @ spec printable_app_name ( ) :: atom | nil
82
88
def printable_app_name do
83
89
Mix.ProjectStack . printable_app_name ( )
84
90
end
@@ -90,6 +96,9 @@ defmodule Mix.Shell do
90
96
This is most commonly used by shell implementations
91
97
but can also be invoked directly.
92
98
99
+ `callback` takes the output data of the command. Its
100
+ return value is ignored.
101
+
93
102
## Options
94
103
95
104
* `:cd` - (since v1.11.0) the directory to run the command in
@@ -101,6 +110,7 @@ defmodule Mix.Shell do
101
110
* `:quiet` - overrides the callback to no-op
102
111
103
112
"""
113
+ @ spec cmd ( String . t ( ) , keyword , ( binary -> term ) ) :: exit_status :: non_neg_integer
104
114
def cmd ( command , options \\ [ ] , callback ) when is_function ( callback , 1 ) do
105
115
callback =
106
116
if options [ :quiet ] do
0 commit comments