Skip to content

Instantly share code, notes, and snippets.

@rozap
Created January 6, 2015 05:10
Show Gist options
  • Save rozap/27e9d47ff0b4be991f1b to your computer and use it in GitHub Desktop.
Save rozap/27e9d47ff0b4be991f1b to your computer and use it in GitHub Desktop.
## in mix.exs
def application do
[
mod: {MyApplication, []},
applications: [:logger]
]
end
## the application module...
defmodule MyApplication do
use Application
def start(type, args) do
IO.puts "Starting.. #{inspect type} #{inspect args}"
## ^^ This prints an empty list, not the args passed in from the task
MyApplication.Supervisor.start_link(args)
end
end
## in my mix.tasts.app.start.ex
def run(args) do
args = args |> parse_args |> defaults |> process
case args do
:help -> :help
args ->
IO.puts "app.start with #{inspect args}"
res = Mix.Task.run("app.start", args)
:timer.sleep(:infinity)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment