Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add basic escriptize support

* Add main/1 to accept command line args
* Change Makefile all target to compile and escriptize
  • Loading branch information...
commit af256bcef7f0d4534f23766ac4f5c64e5f76c0c3 1 parent f142f58
@andrewtj andrewtj authored Adam Lindberg committed
Showing with 29 additions and 1 deletion.
  1. +1 −1  Makefile
  2. +28 −0 src/grapherl.erl
View
2  Makefile
@@ -1,5 +1,5 @@
all:
- @./rebar compile
+ @./rebar compile escriptize
test: force
@./rebar eunit
View
28 src/grapherl.erl
@@ -32,6 +32,7 @@
-copyright("Erlang Solutions Ltd.").
-author("Adam Lindberg <eproxus@gmail.com>").
+-export([main/1]).
-export([applications/2]).
-export([applications/3]).
-export([modules/2]).
@@ -41,6 +42,33 @@
%% API Functions
%%==============================================================================
+%% @hidden
+main(["-applications", Target]) ->
+ main(["-applications", "ebin", Target]);
+main(["-applications", Dir, Target]) ->
+ run(applications, [Dir, Target]);
+main(["-modules", Target]) ->
+ main(["-modules", "ebin", Target]);
+main(["-modules", Dir, Target]) ->
+ run(modules, [Dir, Target, [no_ebin]]);
+main(_) ->
+ io:format(
+ "Usage:~n"
+ " grapherl -applications Target~n"
+ " grapherl -applications Dir Target~n"
+ " grapherl -modules Target~n"
+ " grapherl -modules Dir Target~n"
+ ),
+ halt(1).
+
+run(Fun, Args) ->
+ case apply(?MODULE, Fun, Args) of
+ ok -> io:format("Ok~n");
+ {error, Error} ->
+ io:format("Error:~n~p~n", [Error]),
+ halt(1)
+ end.
+
%% @equiv applications(Dir, Target, [{type, png}])
applications(Dir, Target) ->
applications(Dir, Target, [{type, png}]).

0 comments on commit af256bc

Please sign in to comment.
Something went wrong with that request. Please try again.