This is perhaps a simple question, but I think it gets at some of the fundamental underpinnings of mix
and iex
.
I’m working on an app where it makes sense to have separate .exs
files where users can do some simple (but sometimes lengthy) setup before calling a function or two inside the app, e.g.
MyApp.do_something(["list", "of", "stuff", "maybe", "100s", "of", "lines", "..."])
This command works fine if running from inside iex -S mix
. But if I save a command like that inside of foo.exs
, it can’t magically find the MyApp
module. How can I “tell” a script how to find all of its modules? I could write a Mix task, but it’s important that the users here are given a clean slate of having their own .exs
file, so how does one tell a mix task to “include” and evaluate an .exs
file? (This is more or less what mix test
does, no?)