https://github.com/minhajuddin/mix_script
A build tool which allows you to use mix packages in an elixir script
https://github.com/minhajuddin/mix_script
build elixir escript hex mix
Last synced: about 2 months ago
JSON representation
A build tool which allows you to use mix packages in an elixir script
- Host: GitHub
- URL: https://github.com/minhajuddin/mix_script
- Owner: minhajuddin
- License: mit
- Created: 2017-05-15T18:33:28.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-12-12T15:16:46.000Z (about 8 years ago)
- Last Synced: 2025-10-02T14:57:12.868Z (4 months ago)
- Topics: build, elixir, escript, hex, mix
- Language: Elixir
- Homepage: https://github.com/minhajuddin/mix_script
- Size: 8.79 KB
- Stars: 15
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# MixScript
A build utility that allows you to to use mix packages in an elixir script.
## Example
Let us say, you have a file at `~/scripts/elixir_curl.exs`
```elixir
mix_dep {:httpotion, ">0.0.0"}
if args == [] do
IO.puts "invalid args"
else
IO.inspect HTTPotion.get(hd args)
end
```
You can run the following:
```
# compile our elixir script
mix_script compile ~/scripts/elixir_curl.exs
# run it with args
~/scripts/elixir_curl http://google.com
> %HTTPotion.Response{body: "\n302 Moved\n
302 Moved
\nThe document has moved\nhere.\r\n\r\n",
headers: %HTTPotion.Headers{hdrs: %{"cache-control" => "private",
"content-length" => "261", "content-type" => "text/html; charset=UTF-8",
"date" => "Mon, 15 May 2017 20:31:08 GMT",
"location" => "http://www.google.co.in/?gfe_rd=cr&ei=DBAaWbWTLurx8AeKp4uwCg",
"referrer-policy" => "no-referrer"}}, status_code: 302}
```
## Installation
```
mix escript.install hex mix_script
```
**This will install the binary into your `$HOME/.mix/escripts` directory, so make sure that is part of your `$PATH`**
## TODO
- [ ] Make this more efficient by using a common directory for the mix packages
- [ ] Make it usable via a shebang `#!/usr/bin/env mix_script` which does compilation and execution