zoedsoupe

zoedsoupe

If you were using a CLI library in elixir, do you prefer to use the module and then each function defined generates a CLI cmd or do you prefer to have define macros cmds and handle events for each cmd? examples below

option 1, with using macro and “native” definition using only module attributes:

option 2, with “define” macros and events

I didn’t find any decent library to build CLI commands and options ala rust clap or clojure clapps, so I would like to build my own to Elixir. It will probably leverage the owl package “components” in the future, but firstly I would like to see opinions of the usage proposals!

Showing Posts 1 to 6

dimitarvp

dimitarvp

While I will not address your questions directly, I just want to make sure you’re aware of Owl - A toolkit for writing command-line user interfaces by @fuelen.

zoedsoupe

zoedsoupe OP

yes i’m aware of this library and i would like to leverage those components. But it doesn’t handle self documented commands and options do it doesn’t build a CLI it self, but utilities to be used while run a command.

With my library you can define which commands your CLI would have and process them the way you like, even using own features (:

zachallaun

zachallaun

My recommendation is to start with an option 3: pure data description and manual composition/function calls with no magic. You can add a convenience layer on top after you have a very clear idea of how things should compose and be organized.

Edit: I’d look at NimbleOptions for API inspiration.

dimitarvp

dimitarvp

I see. To be fair Rust’s clap has quite a lot of magic. Try something more manual and explicit for the first iteration IMO.

lud

lud

I built this for myself : GitHub - lud/cli_mate: Another command line parser for Elixir · GitHub

The goal is to have an embeddable library that can be used as a dependency for mix tasks installed by mix archive install hex my_lib, because in that way, the dependencies are not installed.

It is a work in progress, there is no real documentation. But there are other packages as well on hex.pm for that. Plus, it is not (yet) intended to define multiple commands in one file, as I use it in mix tasks, so the command dispatch is directly done by the user when they call mix stuff.command_one vs. mix stuff.command_two.

I like more your second option : define the data in one place, then handle it in one place.

silbermm

silbermm

I was looking for something similar and ended up building my own command parser as well. Take a look at Prompt.Router — prompt v0.10.1 and see if it meets your needs. I’m very open to input and would welcome contributions.

— All posts loaded —

Where Next? Top

Trending in Discussions Top

cblavier
Hey there, It’s been more than a year since we started using LiveView as our main UI library and building a whole library of UI componen...
New
mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
budgie
A little off-topic, but I feel like people here have a good head on their shoulders. I used to be quite good at making software. Was luc...
New
axelson
Hi there! :wave: @frigidcode and I (but mostly him) have been running an Elixir Book club, we’re almost done with Designing Elixir Syste...
New
achempion
I’ve been using Emacs as my main code editor for more than a two years. It’s a custom build version although I’ve tried doom emacs and sp...
New
budgie
I love Elixir. It’s one of 2 programming languages I’ve ever fallen in love with. But I don’t use it anymore. Serverless was the promis...
New
jtormey
Lately I’ve been thinking about how to organize components as a LiveView application grows. One of the pain points I’ve found (for myself...
New

Other Trending Topics Top

GenericJam
Edit: 2026 May 15 - This post is archived. Mob is alive!! Main docs: mob v0.7.11 — Documentation A bit of explanation for the slightly c...
New
garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
KristerV
Hey. Is there anyone here who creates agents in their apps? Not talking about using agents, but creating them. I’m finding it pretty diff...
New
mcass19
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
webofbits
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself. My main conc...
#ai
New
georgeguimaraes
Just published claude-code-elixir, a plugin marketplace for Claude Code with Elixir support. These are the plugins I’ve been using for my...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews