Few notes / questions, mostly around naming or convenience:
- If I end up using such a library I’d appreciate it if I had a convenience function that does both
new()andrun(). Something likecreate_and_run(), maybe? Ormake_and_run()? Or simplystart? - Not sure how intuitive the naming of
paramsanddatais. I’d be a bit more formal and christen theminputandoutput. - Ditto for
pipeline. I get it that you probably wantPlugusers to feel at home but IMO something likeactionis clearer. - In my eyes
{:ok, %{user: user, password_hash: "123"}}and{:error, error_object_or_message}are more idiomatic Elixir. (Note thatEcto.Multipartially follows your pattern but still uses tuples.)
To recap, this is how I’d find the whole thing more readable:
defmodule RegisterUser do
import Commandex
command do
input :email
input :password
output :password_hash
output :user
action :hash_password
action :create_user
action :send_welcome_email
end
...action functions go here
end
Don’t take my criticism seriously if you like your naming. I am only giving you a pure anecdote on what I’d find more intuitive / readable.
Lastly, as a friendly competition, you can take a look at Opus (they seem to like your pipeline naming
).






















