3 ms·
Mix tasks are what you're looking for. You put them inside your application (we have them in /appa/your_app /lib/mix/tasks), define a run/1 function that takes
by _asummers 10y ago
Mix tasks are what you're looking for. You put them inside your application (we have them in /appa/your_app /lib/mix/tasks), define a run/1 function that takes in args, say "use Mix.Task", then you can make sure that things like Ecto are loaded and interact with your program's major entities, or use Poison or whatever it is that you care to do.
- CrystalLangUser 10y ago.... Or you could create a script.rb file, anywhere, and require gems if needed. Then type ruby script.rb. That takes no time at all, and using gems is extremely simple even with RVM if wanted.
- sjtgraham 10y agoThat works for quick and dirty scripts but it's not portable if you want to distribute it to others.