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

AstonJ
As the title says, please share what you’ve been up to with Elixir. Whether that’s been learning it, looking into it, making stuff with i...
2977 94592 917
New
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
heathen
Quite interesting article Google brought me. Didn’t find any mentions about it here. What do you think in general? Would you use togethe...
New
AstonJ
Since we have deprecated our Erlang sections (as we have dedicated Erlang Forums now) let’s add this thread for those who’d like to post ...
New
maennchen
:warning: Security advisory: Decimal DoS vulnerability A vulnerability has been published for decimal where very large exponents can cau...
New
Null-logic-0
What IDE or editor are you using for Elixir development? Personally, I use Zed, and I really like it, but sometimes I wish there were a ...
New

Other Trending Topics Top

marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
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
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
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
webofbits
Aludel - LLM Evaluation Workbench Aludel is an embeddable Phoenix LiveView dashboard for evaluating and comparing LLM prompts across mult...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews