Files
elixir-koans/lib/meditate.ex
Ahmed Ismail edf50fdf80 Add credo to the project and:
- Run mix credo --all to identify possible code optimizations
 - Resolve most of the errors generated by credo such as:
   - Numbers larger than 9999 should be written with underscores: 58_127
   - Modules should have a @moduledoc tag
   - Comparison will always return true
2023-11-10 00:57:21 +05:00

49 lines
997 B
Elixir

defmodule Mix.Tasks.Meditate do
@moduledoc false
use Mix.Task
@shortdoc "Start the koans"
def run(args) do
Application.ensure_all_started(:elixir_koans)
Code.compiler_options(ignore_module_conflict: true)
{parsed, _, _} = OptionParser.parse(args, switches: [])
modules =
parsed
|> initial_module
|> ok?
|> Runner.modules_to_run()
Tracker.set_total(modules)
Tracker.notify_on_complete(self())
set_clear_screen(parsed)
Runner.run(modules)
Tracker.wait_until_complete()
Display.congratulate()
end
defp initial_module(parsed) do
name = Keyword.get(parsed, :koan, "Equalities")
String.to_atom("Elixir." <> name)
end
defp set_clear_screen(parsed) do
if Keyword.has_key?(parsed, :no_clear_screen) do
Display.disable_clear()
end
end
defp ok?(koan) do
if Runner.koan?(koan) do
koan
else
Display.invalid_koan(koan, Runner.modules())
exit(:normal)
end
end
end