Skip to content

Commit

Permalink
Fix default output
Browse files Browse the repository at this point in the history
  • Loading branch information
bsparrow435 committed Nov 16, 2012
1 parent 928b90d commit 15bc49e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 29 deletions.
20 changes: 3 additions & 17 deletions src/riaknostic.erl
Expand Up @@ -62,9 +62,7 @@
{list, $l, "list", undefined, "Describe available diagnostic tasks" },
{usage, $h, "help", undefined, "Display help/usage" },
% should we calc and interpolate the actual cwd for the below?
{export,undefined, "export",undefined, "Package system info in '$CWD/export.zip'" },
{terms, $m, undefined, undefined, "Emit machine readable output" },
{terms, undefined, "mr_out", {string, stdin},"Emit machine readable output to file <mr_out>" }
{export,undefined, "export",undefined, "Package system info in '$CWD/export.zip'" }
]).

-define(USAGE_OPTS, [ O || O <- ?OPTS,
Expand Down Expand Up @@ -135,13 +133,7 @@ run(InputChecks) ->
io:format("No diagnostic messages to report.~n"),
halt(0);
_ ->
case application:get_env(riaknostic, terms) of
{ok, true} ->
{ok, Path} = application:get_env(riaknostic, term_target),
riaknostic_check:write_mr_list(SortedMessages, Path);
undefined ->
lists:foreach(fun riaknostic_check:print/1, SortedMessages)
end,
lists:foreach(fun riaknostic_check:print/1, SortedMessages),
halt(1)
end
end.
Expand Down Expand Up @@ -182,10 +174,4 @@ process_option(list, _) ->
process_option(usage, _) ->
usage;
process_option(export, _) ->
export;
process_option(terms, Result) ->
process_option({terms, stdin}, Result);
process_option({terms, Path}, Result) ->
application:set_env(riaknostic, terms, true),
application:set_env(riaknostic, term_target, Path),
Result.
export.
13 changes: 1 addition & 12 deletions src/riaknostic_check.erl
Expand Up @@ -53,10 +53,7 @@
-export([behaviour_info/1]).
-export([check/1,
modules/0,
print/1,
write_mr_list/2]).

-define(MR_OUTPUT_VSN, 1).
print/1]).

%% @doc The behaviour definition for diagnostic modules.
-spec behaviour_info(atom()) -> 'undefined' | [{atom(), arity()}].
Expand Down Expand Up @@ -101,11 +98,3 @@ print({Level, Mod, Data}) ->
String ->
lager:log(Level, self(), String)
end.

%% @doc Writes a consult/1 consumable file containing the output, instead
%% of the human-readable version printed to stdout.
-spec write_mr_list(list(), string()) -> ok.
write_mr_list(MessageList, FileName) ->
{ok, Fh} = file:open(os:cmd("pwd") ++ FileName, [write]),
io:format(Fh, "~p", [{riaknostic_report, ?MR_OUTPUT_VSN, MessageList}]),
file:close(Fh).

0 comments on commit 15bc49e

Please sign in to comment.