Mix.Task.run isn't available in a compiled release, so the in-prod `bin/microwaveprop eval 'Mix.Tasks.Weather.RebatchAsos.run(...)'` dispatch crashes. Moves the real logic into a plain module (`Microwaveprop.Weather.RebatchAsos`) that both the Mix task and a release eval can call. Uses IO.puts over Mix.shell for the same reason.
26 lines
669 B
Elixir
26 lines
669 B
Elixir
defmodule Mix.Tasks.Weather.RebatchAsos do
|
|
@shortdoc "Collapse pending single-station ASOS jobs into batched jobs"
|
|
|
|
@moduledoc """
|
|
Thin Mix-task wrapper over `Microwaveprop.Weather.RebatchAsos`.
|
|
The real logic lives in the plain module so it's callable from a
|
|
release shell too.
|
|
|
|
Usage:
|
|
|
|
mix weather.rebatch_asos # rewrite
|
|
mix weather.rebatch_asos --dry-run # report only
|
|
"""
|
|
|
|
use Mix.Task
|
|
|
|
alias Microwaveprop.Weather.RebatchAsos
|
|
|
|
@impl Mix.Task
|
|
def run(args) do
|
|
{opts, _, _} = OptionParser.parse(args, strict: [dry_run: :boolean])
|
|
Mix.Task.run("app.start")
|
|
_ = RebatchAsos.run(opts)
|
|
:ok
|
|
end
|
|
end
|