All Projects → danhper → Ex_cli

danhper / Ex_cli

Licence: mit
User friendly CLI apps for Elixir

Programming Languages

elixir
2628 projects

Labels

Projects that are alternatives of or similar to Ex cli

Fzy
🔍 A simple, fast fuzzy finder for the terminal
Stars: ✭ 2,295 (+1154.1%)
Mutual labels:  cli
Athenapdf
Drop-in replacement for wkhtmltopdf built on Go, Electron and Docker
Stars: ✭ 2,160 (+1080.33%)
Mutual labels:  cli
Commander
Test your command line interfaces on windows, linux and osx and nodes viá ssh and docker
Stars: ✭ 183 (+0%)
Mutual labels:  cli
Emuto
manipulate JSON files
Stars: ✭ 180 (-1.64%)
Mutual labels:  cli
Webpack Cli
webpack CLI provides the interface of options webpack uses in its configuration file. The CLI options override options passed in the configuration file.
Stars: ✭ 2,270 (+1140.44%)
Mutual labels:  cli
Msgphp
Reusable domain layers. Shipped with industry standard infrastructure.
Stars: ✭ 182 (-0.55%)
Mutual labels:  cli
Demo
A framework for performing live pre-recorded command line demos in the wild 📼
Stars: ✭ 179 (-2.19%)
Mutual labels:  cli
Tox
Command line driven CI frontend and development task automation tool.
Stars: ✭ 2,523 (+1278.69%)
Mutual labels:  cli
Alive Progress
A new kind of Progress Bar, with real-time throughput, ETA, and very cool animations!
Stars: ✭ 2,940 (+1506.56%)
Mutual labels:  cli
Ezshare
Easily share files, folders and clipboard over LAN - Like Google Drive but without internet
Stars: ✭ 182 (-0.55%)
Mutual labels:  cli
Nba Live
Watch NBA games in the terminal, the content in Chinese only.
Stars: ✭ 181 (-1.09%)
Mutual labels:  cli
Piano Rs
A multiplayer piano using UDP sockets that can be played using computer keyboard, in the terminal
Stars: ✭ 180 (-1.64%)
Mutual labels:  cli
Brightness Cli
Change the screen brightness
Stars: ✭ 182 (-0.55%)
Mutual labels:  cli
Procsd
Manage your application processes in production hassle-free like Heroku CLI with Procfile and Systemd
Stars: ✭ 181 (-1.09%)
Mutual labels:  cli
Appfairy
A CLI tool to Migrate a Webflow project into a React app
Stars: ✭ 183 (+0%)
Mutual labels:  cli
Ni
💡 Use the right package manager
Stars: ✭ 179 (-2.19%)
Mutual labels:  cli
Nodejs Master Class
🛠 This repository contains the homework assignment for Node.js Master Class that is focused on building a RESTful API, web app GUI, and a CLI in plain Node JS with no NPM or 3rd-party libraries
Stars: ✭ 182 (-0.55%)
Mutual labels:  cli
Neomutt
✉️ Teaching an Old Dog New Tricks -- IRC: #neomutt on irc.libera.chat
Stars: ✭ 2,343 (+1180.33%)
Mutual labels:  cli
Wowcup
⚽ 💻 The finest Worldcup 2018 CLI.
Stars: ✭ 183 (+0%)
Mutual labels:  cli
Gitmux
💻 Git in your tmux status bar
Stars: ✭ 180 (-1.64%)
Mutual labels:  cli

ExCLI

Build Status Coverage Status Hex.pm

User friendly CLI apps for Elixir.

Screencast

Here is a small screencast of what a generated CLI app looks like.

screencast

Installation

Add ex_cli to your list of dependencies in mix.exs:

def deps do
  [{:ex_cli, "~> 0.1.0"}]
end

Usage

The basic usage is to use ExCLI.DSL to define your CLI, and ExCLI.run to run it. Here is a sample application:

defmodule MyApp.SampleCLI do
  use ExCLI.DSL

  name "mycli"
  description "My CLI"
  long_description ~s"""
  This is my long description
  """

  option :verbose, count: true, aliases: [:v]

  command :hello do
    aliases [:hi]
    description "Greets the user"
    long_description """
    Gives a nice a warm greeting to whoever would listen
    """

    argument :name
    option :from, help: "the sender of hello"

    run context do
      if context.verbose > 0 do
        IO.puts("Running hello command")
      end
      if from = context[:from] do
        IO.write("#{from} says: ")
      end
      IO.puts("Hello #{context.name}!")
    end
  end
end

ExCLI.run!(MyApp.SampleCLI)

Which can be used in the following way.

sample_cli hello -vv world --from me

or using the command's alias:

sample_cli hi -vv world --from me

The application usage will be shown if the parsing fails. The above example would show:

usage: mycli [--verbose] <command> [<args>]

Commands
   hello   Greets the user

escript and mix integration

You can very easily generate a mix task or an escript using ExCLI

escript

Pass escript: true to the use ExCLI.DSL and set the module as escript :main_module:

# lib/my_escript_cli.ex
defmodule MyEscriptCLI do
  use ExCLI.DSL, escript: true
end

# mix.exs
defmodule MyApp.Mixfile do
  def project do
    [app: :my_app,
     escript: [main_module: MyEscriptCLI]]
  end
end

mix integration

Pass mix_task: TASK_NAME to the use ExCLI.DSL.

# lib/my_cli_task.ex
defmodule MyCLITask do
  use ExCLI.DSL, mix_task: :great_task
end

You can then run

mix great_task

and get nicely formatted help with

mix help great_task

Documentation

Check out the documentation for more information.

Roadmap

  • [x] Command parser

    The command parser is now working and should be enough for a good number of tasks.

  • [x] Integration with escript and mix

    ExCLI.DSL can generate a module compatible with escript.build as well as a mix task.

  • [x] Usage generation

    A nicely formatted usage is generated from the DSL.

  • [ ] Help command

    Then the goal will be to add a help command which can be used as app help command to show help about command.

  • [ ] Command parser improvements

    When the usage and help parts are done, there are a few improvements that will be nice to have in the command parser:

    • [x] the ability to set a default command
    • [ ] the ability to easily delegate a command to another module
    • [x] command aliases
  • [ ] Man page generation

    When all this is done, the last part will to generate documentation in man page and markdown formats, which will probably be done as a mix task.

Contributing

Contributions are very welcome, feel free to open an issue or a PR.

I am also looking for a better name, ideas are welcome!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].