Search code examples
elixirelixir-iex

Is There A Built In IEX Command To Invoke Formatting?


I checked h and h(IEx) and didn't come up with anything.

I am sure I can shell out to a command prompt and run "mix format" but I was wondering if I'm missing something. Is there any command analogous to recompile/0 or r/1 for iex to allow me to reformat the source files in my project?


Solution

  • You can invoke the format mix task by calling Mix.Tasks.Format.run/1 using whatever arguments you'd pass to mix format. For example, mix format "**/*.{ex,exs}" would be:

    iex(1)> Mix.Tasks.Format.run ["**/*.{ex,exs}"]
    :ok