Permalink
Browse files

Added 'verify' command line command

  • Loading branch information...
yrashk committed Jan 28, 2011
1 parent 899319d commit 1bb458cc0803cd2e26caf8f416021a15745cc7ea
Showing with 35 additions and 0 deletions.
  1. +7 −0 README.md
  2. +28 −0 src/agner.erl
View
@@ -89,6 +89,13 @@ were the case for `agner spec`.
List the versions of the given `PACKAGE`
+ agner verify [SPEC FILENAME (agner.config by default)]
+
+Verify specification file for correctness; intended to be used to package maintainers to simplify
+their workflow. Currently checks whether 1) specification is a valid file that can be parsed,
+2) the URL can be fetched. In the future it will also offer a deeper analysis of specification
+correctness.
+
Packaging
=========
View
@@ -100,6 +100,34 @@ main(["fetch"|Args]) ->
end,
stop();
+main(["verify"|Args]) ->
+ OptSpec = [
+ {spec, undefined, undefined, {string, "agner.config"}, "Specification file (agner.config by default)"}
+ ],
+ start(),
+ {ok, {Opts, _}} = getopt:parse(OptSpec, Args),
+ SpecFile = proplists:get_value(spec, Opts),
+ case file:consult(SpecFile) of
+ {error, Reason} ->
+ io:format("ERROR: Can't read ~s: ~p~n",[SpecFile, Reason]);
+ {ok, Spec} ->
+ URL = proplists:get_value(url, Spec),
+ {A,B,C} = now(),
+ N = node(),
+ TmpFile = lists:flatten(io_lib:format("/tmp/agner-~p-~p.~p.~p",[N,A,B,C])),
+ case (catch agner_download:fetch(URL,TmpFile)) of
+ ok ->
+ io:format("~nPASSED~n");
+ {'EXIT', {Reason, _}} ->
+ io:format("~nEROR: Can't fetch ~p: ~p~n",[URL, Reason]);
+ {error, Reason} ->
+ io:format("~nEROR: Can't fetch ~p: ~p~n",[URL, Reason])
+ end,
+ os:cmd("rm -rf " ++ TmpFile)
+ end,
+ stop();
+
+
main(_) ->
OptSpec = [
{command, undefined, undefined, string, "Command to be executed (e.g. spec)"}

0 comments on commit 1bb458c

Please sign in to comment.