Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added --add-path option for fetch --compile

  • Loading branch information...
commit 6e75a537e5eb30322ea1f71e670edcd1dcd67c1b 1 parent ef417db
@yrashk yrashk authored
Showing with 15 additions and 2 deletions.
  1. +4 −1 README.md
  2. +11 −1 src/agner_main.erl
View
5 README.md
@@ -83,13 +83,16 @@ If `-h` or `--homepage` is present, it will also open browser with the package's
homepage.
agner fetch PACKAGE [DESTDIR] [-v/--version package_version] [-c/--compile]
+ [-a/--add-path]
Fetch a given `PACKAGE` to either the current directory or,
optionally, to the `DESTDIR` directory. The version constraint is as
were the case for `agner spec`.
If `-c` or `--compile` is supplied, Agner will try to compile fetched package.
-Currenly only rebar compatible packages can be built.
+Currenly only rebar compatible packages can be built. If you also specify
+`-a` (or `--add-path`) Agner will add path to a newly built package to your
+HOME/.erlang
agner versions PACKAGE
View
12 src/agner_main.erl
@@ -43,7 +43,8 @@ arg_proplist() ->
{package, undefined, undefined, string, "Package name"},
{directory, undefined, undefined, string, "Directory to check package out to"},
{version, $v, "version", {string, "@master"}, "Version"},
- {compile, $c, "compile", {boolean, false}, "Compile fetched package"}
+ {compile, $c, "compile", {boolean, false}, "Compile fetched package"},
+ {addpath, $a, "add-path", {boolean, false}, "Add path to compiled package to .erlang"}
]}},
{"verify",
{verify,
@@ -191,6 +192,15 @@ handle_command(fetch, Opts) ->
file:set_cwd(Cwd);
_ ->
io:format("ERROR: Can't compile rebar-incompatible packages at this moment. To be fixed.~n")
+ end,
+ case proplists:get_value(addpath, Opts) of
+ true ->
+ {ok, F} = file:open(filename:join(os:getenv("HOME"),".erlang"),
+ [append]),
+ file:write(F, io_lib:format("code:add_patha(\"~s/ebin\"). %% {agner, ~s}~n", [Directory, Package])),
+ file:close(F);
+ false ->
+ ignore
end;
false ->
ignore
Please sign in to comment.
Something went wrong with that request. Please try again.