elixir-lang/elixir — pull request #2974 by alco (2014-12-30 20:24:12+00:00)
Title: [WIP] escript-related mix tasks

This PR implements a few additional escript-related mix tasks, outlined in [this proposal](https://groups.google.com/d/msg/elixir-lang-core/LEr5Vjd1gys/A8WTbC1vmhwJ).

Technical details:

* `mix escript.install` has been added that works similarly to `mix archive.install`: it takes a path or a URL to an arbitrary file and puts it under `~/.mix/escripts`.

* `mix escript` lists all executable files under `~/.mix/escripts`.

* `mix escript.uninstall` removes the file with the given name from `~/.mix/escripts`.

Additional concerns:

* the ability to escript.install a prebuilt escript has been added because archive.install could already do that for .ez files, and it makes even more sense to have this work with escripts as they are not dependent on the installed Elixir version.

* there is no environment variable MIX_ESCRIPTS because, as I mentioned, escript are generally independent of the installed Elixir version.

TODO:

* [ ] to keep `archive.install` and `escript.install` symmetric, both should be able to fetch repositories and hex packages. The package will be fetched into a temporary directory, in the case of an escript it will also fetch dependencies. Then everything is compiled and subsequently `archive.install` or `escript.install` is called with the resulting archive or escript file. This makes it possible to host mix tasks on hex.pm too.

* [ ] the command-line invocation syntax is just an idea. I have considered lots of alternatives, but would like to hear what the team thinks about it first. We can't really say that it is similar to the dep syntax in mix.exs because that would mean having something like this:

mix escript.install phoenix
mix escript.install phoenix 1.0.2
mix escript.install phoenix github phoenixframework/phoenix

I would much rather have the Mix task infer the source type from the URL given to it. The biggest problem is then to distinguish a local path from the package name.

* if we allow both archives and escripts to be fetched from hex.pm, it may be confusing in which way a given package is supposed to be used: as a dependency, as an archive, or as an escript. Perhaps, hex.pm could indicate that visually in some way, or via the project's name.