Skip to content

Commit 3b4954b

Browse files
author
José Valim
committed
Merge pull request #1643 from pminten/elixirc-silent
Add --verbose to elixirc
2 parents fb30101 + 4c28f32 commit 3b4954b

File tree

4 files changed

+18
-3
lines changed

4 files changed

+18
-3
lines changed

bin/elixirc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ if [ $# -eq 0 ] || [ "$1" = "--help" ] || [ "$1" = "-h" ]; then
77
--no-debug-info Do not attach debug info to compiled modules
88
--ignore-module-conflict
99
--warnings-as-errors Treat warnings as errors and return non-zero exit code
10+
--verbose Print informational messages.
1011
1112
** Options given after -- are passed down to the executed code
1213
** Options can be passed to the erlang runtime using ELIXIR_ERL_OPTS" >&2

bin/elixirc.bat

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ echo --no-docs Do not attach documentation to compiled modules
1414
echo --no-debug-info Do not attach debug info to compiled modules
1515
echo --ignore-module-conflict
1616
echo --warnings-as-errors Treat warnings as errors and return non-zero exit code
17+
echo --verbose Print informational messages.
1718
echo.
1819
echo ** Options marked with (*) can be given more than once
1920
echo ** Options given after -- are passed down to the executed code

lib/elixir/lib/kernel/cli.ex

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ defmodule Kernel.CLI do
22
@moduledoc false
33

44
defrecord Config, commands: [], output: ".", compile: [],
5-
halt: true, compiler_options: [], errors: []
5+
halt: true, compiler_options: [], errors: [],
6+
verbose_compile: false
67

78
@doc """
89
This is the API invoked by Elixir boot process.
@@ -216,6 +217,10 @@ defmodule Kernel.CLI do
216217
defp process_compiler(["--warnings-as-errors"|t], config) do
217218
process_compiler t, config.update_compiler_options([{:warnings_as_errors, true}|&1])
218219
end
220+
221+
defp process_compiler(["--verbose"|t], config) do
222+
process_compiler t, config.verbose_compile(true)
223+
end
219224

220225
defp process_compiler([h|t] = list, config) do
221226
case h do
@@ -343,7 +348,7 @@ defmodule Kernel.CLI do
343348
if files != [] do
344349
Code.compiler_options(config.compiler_options)
345350
Kernel.ParallelCompiler.files_to_path(files, config.output,
346-
each_file: fn file -> IO.puts "Compiled #{file}" end)
351+
each_file: fn file -> if config.verbose_compile do IO.puts "Compiled #{file}" end end)
347352
:ok
348353
else
349354
{ :error, "--compile : No files matched patterns #{Enum.join(patterns, ",")}" }

lib/elixir/test/elixir/kernel/cli_test.exs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,15 @@ defmodule Kernel.CLI.CompileTest do
7171

7272
test :compile_code do
7373
fixture = fixture_path "compile_sample.ex"
74-
assert elixirc('#{fixture} -o #{tmp_path}') ==
74+
assert elixirc('#{fixture} -o #{tmp_path}') == ''
75+
assert File.regular?(tmp_path "Elixir.CompileSample.beam")
76+
after
77+
File.rm(tmp_path("Elixir.CompileSample.beam"))
78+
end
79+
80+
test :compile_code_verbose do
81+
fixture = fixture_path "compile_sample.ex"
82+
assert elixirc('#{fixture} -o #{tmp_path} --verbose') ==
7583
'Compiled #{fixture}\n'
7684
assert File.regular?(tmp_path "Elixir.CompileSample.beam")
7785
after

0 commit comments

Comments
 (0)