brettbeatty

brettbeatty OP

At my work we build a lot of mix tasks for backfills and other maintenance tasks. Even with OptionParser we seem to copy a lot of boilerplate between tasks. I’m wondering if folks would prefer a more batteries-included solution for building mix tasks, maybe even a domain-specific language for declaring options and such.

I’ve built a library called Executive, not published on Hex, and I’m looking for feedback on whether folks would use something like it (is there already something like it I’m missing?) or anything y’all would change.

It provides a mix task for generating mix tasks:

mix executive.gen.task my_object.do_something --uuid id --required \
  --string cursor --datetime after --pos-integer batch_size --start-application

Running that task would generate a mix task that could get called as

mix my_object.do_something --id a7cde5bd-3878-42f9-b439-d49fd4ba37f9 \
  --cursor b219859c98bb --after 2024-01-15T12:34:56Z --batch-size 500

Inside the mix task, you declare a bunch of options like this:

@optdoc "whether you want a or b or c"
option :my_option, {:enum, [:a, :b, :c]}

And Executive implements c:Mix.Task.run/1, parses the options assertively, and calls c:Executive.Task.run/2 with the parsed options. But since the options are declared, it can also build docs and types and such for the task.

Where Next? Top

Trending in RFCs Top

nikolis
BeamScope Why I created this: Needed some very particular metrics regarding the state of my Elixir cluster in a relatively small project...
New

Other Trending Topics Top

JesseHerrick
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve. They are GUI (Emerge) and State management (S...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
ausimian
Emily is an Elixir library that runs Nx computations on Apple’s MLX. Install it as the default Nx backend and Nx, defn, Axon, Nx.Serving,...
New
type1fool
I just stumbled on a newly redesigned elixir-lang.org. :tada: It looks like @Software_Mansion did the work, and I think it is generally a...
New

We're in Beta

About us Mission Statement