Created
January 6, 2015 05:10
-
-
Save rozap/27e9d47ff0b4be991f1b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## 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