Helpers for --help / -h handling in mob_dev Mix tasks.
Mix has mix help <task> built in (reads the task module's
@moduledoc), but users from outside the Elixir ecosystem expect
<command> --help to work too. This module gives each task a
one-line opt-in:
def run(args) do
if MobDev.TaskHelp.help_requested?(args) do
MobDev.TaskHelp.print_module_help(__MODULE__)
else
# normal flow…
end
endPublic API is intentionally tiny — two predicates and a printer —
so a future change to where @moduledoc is stored (or how it gets
rendered) only ripples through one file.
Summary
Functions
True when argv contains --help or -h as a standalone arg.
Prints task_module's @moduledoc to stdout.
Functions
True when argv contains --help or -h as a standalone arg.
iex> MobDev.TaskHelp.help_requested?(["--help"])
true
iex> MobDev.TaskHelp.help_requested?(["-h"])
true
iex> MobDev.TaskHelp.help_requested?(["--device", "foo"])
false
iex> MobDev.TaskHelp.help_requested?([])
false
@spec print_module_help(module()) :: :ok
Prints task_module's @moduledoc to stdout.
Falls back to a small "no docs available" message if the module
has no @moduledoc (which shouldn't happen for any mob_dev task
but the fallback keeps print_module_help/1 total).