Skip to content

Commit 61839b4

Browse files
authored
Improve documentation in Mix.Shell (#12581)
1 parent 50266c4 commit 61839b4

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

lib/mix/lib/mix/shell.ex

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ defmodule Mix.Shell do
1919
@doc """
2020
Executes the given command and returns its exit status.
2121
22-
Shortcut for `cmd/2` with empty options.
22+
Shortcut for `c:cmd/2` with empty options.
2323
"""
2424
@callback cmd(command :: String.t()) :: integer
2525

@@ -28,6 +28,8 @@ defmodule Mix.Shell do
2828
2929
## Options
3030
31+
This callback should support the following options:
32+
3133
* `:print_app` - when `false`, does not print the app name
3234
when the command outputs something
3335
@@ -38,6 +40,9 @@ defmodule Mix.Shell do
3840
3941
* `:env` - environment options to the executed command
4042
43+
* `:cd` - (since v1.11.0) the directory to run the command in
44+
45+
All the built-in shells support these.
4146
"""
4247
@callback cmd(command :: String.t(), options :: keyword) :: integer
4348

@@ -79,6 +84,7 @@ defmodule Mix.Shell do
7984
goal is to avoid printing the application name
8085
multiple times.
8186
"""
87+
@spec printable_app_name() :: atom | nil
8288
def printable_app_name do
8389
Mix.ProjectStack.printable_app_name()
8490
end
@@ -90,6 +96,9 @@ defmodule Mix.Shell do
9096
This is most commonly used by shell implementations
9197
but can also be invoked directly.
9298
99+
`callback` takes the output data of the command. Its
100+
return value is ignored.
101+
93102
## Options
94103
95104
* `:cd` - (since v1.11.0) the directory to run the command in
@@ -101,6 +110,7 @@ defmodule Mix.Shell do
101110
* `:quiet` - overrides the callback to no-op
102111
103112
"""
113+
@spec cmd(String.t(), keyword, (binary -> term)) :: exit_status :: non_neg_integer
104114
def cmd(command, options \\ [], callback) when is_function(callback, 1) do
105115
callback =
106116
if options[:quiet] do

0 commit comments

Comments
 (0)