aboutsummaryrefslogtreecommitdiffstats
path: root/lib/syntax_tools
diff options
context:
space:
mode:
authorSiri Hansen <[email protected]>2014-01-28 15:34:39 +0100
committerSiri Hansen <[email protected]>2014-01-28 15:34:49 +0100
commit127cd6d32a8f5e3ffd56b13ea8f333eeffa253a2 (patch)
tree34718709cdccfe99cb05b0822ff0accd1d24e988 /lib/syntax_tools
parent04dbc5f39bd8816f3982690d4a3b5913c605c0d0 (diff)
parenta857d28603ad674c40a977249c1b6ae8d29c1f6c (diff)
downloadotp-127cd6d32a8f5e3ffd56b13ea8f333eeffa253a2.tar.gz
otp-127cd6d32a8f5e3ffd56b13ea8f333eeffa253a2.tar.bz2
otp-127cd6d32a8f5e3ffd56b13ea8f333eeffa253a2.zip
Merge branch 'feat/erl_tidy_print_to_stdout'
* feat/erl_tidy_print_to_stdout: Added documenation for the new option describing what it does. Add initial implementation of having erl_tidy print to screen instead of writing to the file provided. The reason for this is that you may want to have an intermediary step between saving the tidied file and using the output. OTP-11632
Diffstat (limited to 'lib/syntax_tools')
-rw-r--r--lib/syntax_tools/src/erl_tidy.erl23
1 files changed, 20 insertions, 3 deletions
diff --git a/lib/syntax_tools/src/erl_tidy.erl b/lib/syntax_tools/src/erl_tidy.erl
index 0c149634f6..7444d8dc67 100644
--- a/lib/syntax_tools/src/erl_tidy.erl
+++ b/lib/syntax_tools/src/erl_tidy.erl
@@ -269,6 +269,13 @@ file(Name) ->
%% is typically most useful if the `verbose' flag is enabled, to
%% generate reports about the program files without affecting
%% them. The default value is `false'.</dd>
+%%
+%% <dt>{stdout, boolean()}</dt>
+%%
+%% <dd>If the value is `true', instead of the file being written
+%% to disk it will be printed to stdout. The default value is
+%% `false'.</dd>
+%%
%% </dl>
%%
%% See the function `module/2' for further options.
@@ -309,9 +316,15 @@ file_2(Name, Opts) ->
true ->
ok;
false ->
- write_module(Tree, Name, Opts1),
- ok
- end.
+ case proplists:get_bool(stdout, Opts1) of
+ true ->
+ print_module(Tree, Opts1),
+ ok;
+ false ->
+ write_module(Tree, Name, Opts1),
+ ok
+ end
+ end.
read_module(Name, Opts) ->
verbose("reading module `~ts'.", [filename(Name)], Opts),
@@ -399,6 +412,10 @@ write_module(Tree, Name, Opts) ->
throw(R)
end.
+print_module(Tree, Opts) ->
+ Printer = proplists:get_value(printer, Opts),
+ io:format(Printer(Tree, Opts)).
+
output(FD, Printer, Tree, Opts) ->
io:put_chars(FD, Printer(Tree, Opts)),
io:nl(FD).