Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add --keep-rocking switch #435

Merged
merged 2 commits into from
Mar 2, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.