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!
Trending in Discussions
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...
New
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
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
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
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
:warning: Security advisory: Decimal DoS vulnerability
A vulnerability has been published for decimal where very large exponents can cau...
New
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
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
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
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
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself.
My main conc...
New
Aludel - LLM Evaluation Workbench
Aludel is an embeddable Phoenix LiveView dashboard for evaluating and comparing LLM prompts across mult...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixirconf-us
- #ai
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming
![defmodule MyCLI do use Nexus @doc """ Answers "fizz" on "buzz" input and vice-versa """ @cmd_type {:enum, ["fizz", "buzz"]} @required true def fizzbuzz(input) do # logic... end end](https://forum.elixirforum.com/uploads/default/original/3X/8/c/8cdc1008d435b0f8451384d952b033604797c9b3.jpeg)











Showing Posts 1 to 6- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
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
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
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
I see. To be fair Rust’s
claphas quite a lot of magic. Try something more manual and explicit for the first iteration IMO.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_onevs.mix stuff.command_two.I like more your second option : define the data in one place, then handle it in one place.
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.