I was having a hard time running tests and wrapping my tiny app with Burrito so I came up with this strategy, but I wasn’t sure if this is the best way to go about it.
Is there a simpler way to do it?
# config.exs
import Config
config :pled, compile_env: Mix.env()
# application.ex
defmodule Pled.Application do
use Application
alias Pled.CLI
@impl true
def start(_type, _args) do
env = Application.get_env(:pled, :compile_env)
if env == :test do
children = []
opts = [strategy: :one_for_one, name: Pled.Supervisor]
Supervisor.start_link(children, opts)
else
Burrito.Util.Args.argv()
|> CLI.parse_args()
|> CLI.handle_command()
System.halt(0)
end
end
end






















