Skip to content

Commit

Permalink
Merge pull request #435 from fenek/keep-going
Browse files Browse the repository at this point in the history
Add --keep-rocking switch
  • Loading branch information
Brujo Benavides authored Mar 2, 2017
2 parents 0cf579c + 5a7ccc0 commit 8275126
Showing 1 changed file with 28 additions and 11 deletions.
39 changes: 28 additions & 11 deletions src/elvis.erl
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,28 @@ main(Args) ->
-spec option_spec_list() -> [getopt:option_spec()].
option_spec_list() ->
Commands = "Provide the path to the configuration file. "
++ "When none is provided elvis checks if there's "
++ "an elvis.config file.",
"When none is provided elvis checks if there's "
"an elvis.config file.",
OutputFormat = "It allows you to display the results in plain text. When "
++ "none is provided elvis displays the results in colors. "
++ "The options allowed are (plain | colors).",
"none is provided elvis displays the results in colors. "
"The options allowed are (plain | colors).",
KeepRocking = "Won't stop rocking on first error"
" when given a list of files",
[
{help, $h, "help", undefined, "Show this help information."},
{config, $c, "config", string, Commands},
{commands, undefined, "commands", undefined, "Show available commands."},
{output_format, undefined, "output-format", string, OutputFormat},
{version, $v, "version", undefined, "Specify the elvis current version."},
{code_path, $p, "code-path", string, "Add the directory in the code path."}
{help, $h, "help", undefined,
"Show this help information."},
{config, $c, "config", string,
Commands},
{commands, undefined, "commands", undefined,
"Show available commands."},
{output_format, undefined, "output-format", string,
OutputFormat},
{version, $v, "version", undefined,
"Specify the elvis current version."},
{code_path, $p, "code-path", string,
"Add the directory in the code path."},
{keep_rocking, $k, "keep-rocking", undefined,
KeepRocking}
].

-spec process_options([atom()], [string()]) -> ok.
Expand Down Expand Up @@ -93,6 +103,9 @@ process_options([commands | Opts], Cmds, Config) ->
process_options([{output_format, Format} | Opts], Cmds, Config) ->
ok = application:set_env(elvis, output_format, list_to_atom(Format)),
process_options(Opts, Cmds, Config);
process_options([keep_rocking | Opts], Cmds, Config) ->
ok = application:set_env(elvis, keep_rocking, true),
process_options(Opts, Cmds, Config);
process_options([version | Opts], Cmds, Config) ->
version(),
process_options(Opts, Cmds, Config);
Expand Down Expand Up @@ -181,6 +194,10 @@ version() ->
rock_one_song(FileName, Config) ->
F = atom_to_list(FileName),
case elvis_core:rock_this(F, Config) of
{fail, _} -> elvis_utils:erlang_halt(1);
{fail, _} ->
case application:get_env(elvis, keep_rocking, false) of
false -> elvis_utils:erlang_halt(1);
true -> ok
end;
ok -> ok
end.

0 comments on commit 8275126

Please sign in to comment.