danhper / ex_cli Goto Github PK
View Code? Open in Web Editor NEWUser friendly CLI apps for Elixir
Home Page: https://hex.pm/packages/ex_cli
License: MIT License
User friendly CLI apps for Elixir
Home Page: https://hex.pm/packages/ex_cli
License: MIT License
I am also looking for a better name, ideas are welcome!
So let's discuss it here. :-)
Might be me, but I fail to see how to actually use this. There are examples that describe how to use the ExCLI DSL, so that is nice and shiny; but how is one supposed to go from there to an actual script, that can be run from the CLI?
This code example
# lib/my_escript_cli.ex
defmodule MyEscriptCLI do
use ExCLI, escript: true
end
is probably wrong, and should be
# lib/my_escript_cli.ex
defmodule MyEscriptCLI do
use ExCLI.DSL, escript: true
end
instead
option :lon, help: "The venue's longitude", type: :float
% mix venue -v add 'Temple of Boom' --lat 53.8020657 --lon -1.5319708
No argument provided for 'lon'
% mix venue -v add 'Temple of Boom' --lat 53.8020657 --lon '-1.5319708'
No argument provided for 'lon'
Full script:
defmodule BandTracker.Venue do
use ExCLI.DSL, mix_task: :venue
name "BandTracker.Venue"
description "Venue operations"
option :verbose, count: true, aliases: [:v]
command :add do
aliases [:a]
description "Add a new venue"
argument :name, help: "The venue's name"
option :lat, help: "The venue's latitude", type: :float
option :lon, help: "The venue's longitude", type: :float
run context do
if context.verbose > 0 do
IO.puts("Adding new venue...")
end
name = context[:name]
lat = context[:lat]
lon = context[:lon]
IO.write("Name: #{name}, latitude: #{lat}, longitude: #{lon}")
end
end
end
The README and module doc both use the :help and long_description dsl options but I can't seem to get them to print when I use the cli. Any idea how I can use them?
Thanks again for this library! I'm finding it really helpful on a little side/learning project I've been working on.
I recently found myself wanting to provide aliases for my commands so that I could use a shorter name on the command line. One way to do this would be to add an aliases
option to Command
, and then modify command lookup to take aliases into account.
However, I see in the README that one of the roadmap ideas is
fuzzy handling of command (i.e. npm insta will run npm install)
A first cut at fuzzy handling would likely involve just matching prefixes; that could be improved later if needed. Doing a prefix match would also address my need, as the aliases I want to define are prefixes of the full command names.
I've looked through the code, and I don't think it would be terribly difficult to implement either of these ideas.
I'm willing to start working on a PR for this, but first I'd like to know which of these two directions you'd prefer.
Do you prefer the fuzzy (starting with prefix) matching? Or do you prefer the alias idea?
My time is somewhat limited, so I can't guarantee how fast I can get this done, but I'm willing to do the work on it.
Thanks for this library! It's just what I needed for a little learning project I'm working on!
When you have time, could you please release a new version that has the latest fixes included? I'm seeing the warnings that were addressed in 8175d9c.
Thanks!
Great package!
I think it'd be really nice if this was possible
use ExCLI.DSL, mix_task: :'mytask.install'
So it conformed to mix command rules (like 'mix deps.get' 'mix coveralls.detail' etc)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.