Skip to content

Commit 7061c37

Browse files
committed
Add --no-compile to mix format
Closes #15256.
1 parent 74bb90a commit 7061c37

3 files changed

Lines changed: 14 additions & 4 deletions

File tree

lib/elixir/lib/option_parser.ex

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -952,8 +952,14 @@ defmodule OptionParser do
952952

953953
case types |> List.delete(:keep) |> List.first(:string) do
954954
:boolean ->
955-
base = "#{to_switch(name)}, #{to_switch(name, "--no-")}"
956-
add_aliases(base, name, reverse_aliases)
955+
case to_switch(name) do
956+
"--no-" <> _ = switch ->
957+
add_aliases(switch, name, reverse_aliases)
958+
959+
switch ->
960+
base = "#{switch}, #{to_switch(name, "--no-")}"
961+
add_aliases(base, name, reverse_aliases)
962+
end
957963

958964
type ->
959965
base = "#{to_switch(name)} #{String.upcase(Atom.to_string(type))}"

lib/elixir/test/elixir/option_parser_test.exs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ defmodule OptionParserTest do
173173
--debug, --no-debug (alias: -d)
174174
--files STRING (alias: -f) (may be given more than once)
175175
--name STRING (alias: -n)
176+
--no-exit
176177
--verbose, --no-verbose (alias: -v)\
177178
"""
178179

@@ -183,7 +184,8 @@ defmodule OptionParserTest do
183184
count: :integer,
184185
verbose: :boolean,
185186
debug: :boolean,
186-
files: :keep
187+
files: :keep,
188+
no_exit: :boolean
187189
],
188190
aliases: [n: :name, c: :count, v: :verbose, d: :debug, f: :files]
189191
)

lib/mix/lib/mix/tasks/format.ex

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@ defmodule Mix.Tasks.Format do
1313
$ mix format mix.exs "lib/**/*.{ex,exs}" "test/**/*.{ex,exs}"
1414
1515
If any of the files is `-`, then the input is read from stdin and the output
16-
is written to stdout.
16+
is written to stdout. In such cases, because `mix format` may still compile
17+
before running, you may want to pass the `--no-compile` flag.
1718
1819
## Formatting options
1920
@@ -199,6 +200,7 @@ defmodule Mix.Tasks.Format do
199200
check_equivalent: :boolean,
200201
check_formatted: :boolean,
201202
no_exit: :boolean,
203+
no_compile: :boolean,
202204
dot_formatter: :string,
203205
dry_run: :boolean,
204206
verbose: :boolean,

0 commit comments

Comments
 (0)