{"id":13443106,"url":"https://github.com/danhper/ex_cli","last_synced_at":"2025-12-12T00:29:48.088Z","repository":{"id":43115669,"uuid":"58161829","full_name":"danhper/ex_cli","owner":"danhper","description":"User friendly CLI apps for Elixir","archived":false,"fork":false,"pushed_at":"2019-04-27T23:52:17.000Z","size":76,"stargazers_count":213,"open_issues_count":3,"forks_count":15,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-04-14T11:08:00.538Z","etag":null,"topics":["cli","commandparser","elixir"],"latest_commit_sha":null,"homepage":"https://hex.pm/packages/ex_cli","language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/danhper.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-05-05T21:30:09.000Z","updated_at":"2024-04-07T21:16:06.000Z","dependencies_parsed_at":"2022-08-19T09:01:17.422Z","dependency_job_id":null,"html_url":"https://github.com/danhper/ex_cli","commit_stats":null,"previous_names":["tuvistavie/ex_cli"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danhper%2Fex_cli","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danhper%2Fex_cli/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danhper%2Fex_cli/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danhper%2Fex_cli/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/danhper","download_url":"https://codeload.github.com/danhper/ex_cli/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230542288,"owners_count":18242332,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","commandparser","elixir"],"created_at":"2024-07-31T03:01:56.152Z","updated_at":"2025-12-12T00:29:48.060Z","avatar_url":"https://github.com/danhper.png","language":"Elixir","readme":"# ExCLI\n\n[![Build Status](https://travis-ci.org/danhper/ex_cli.svg?branch=master)](https://travis-ci.org/danhper/ex_cli)\n[![Coverage Status](https://coveralls.io/repos/github/danhper/ex_cli/badge.svg?branch=master)](https://coveralls.io/github/danhper/ex_cli?branch=master)\n[![Hex.pm](https://img.shields.io/hexpm/v/ex_cli.svg)](https://hex.pm/packages/ex_cli)\n\nUser friendly CLI apps for Elixir.\n\n## Screencast\n\nHere is a small screencast of what a generated CLI app looks like.\n\n![screencast][2]\n\n## Installation\n\nAdd `ex_cli` to your list of dependencies in `mix.exs`:\n\n```elixir\ndef deps do\n  [{:ex_cli, \"~\u003e 0.1.0\"}]\nend\n```\n\n## Usage\n\nThe basic usage is to use `ExCLI.DSL` to define your CLI, and `ExCLI.run` to run it.\nHere is a sample application:\n\n\n```elixir\ndefmodule MyApp.SampleCLI do\n  use ExCLI.DSL\n\n  name \"mycli\"\n  description \"My CLI\"\n  long_description ~s\"\"\"\n  This is my long description\n  \"\"\"\n\n  option :verbose, count: true, aliases: [:v]\n\n  command :hello do\n    aliases [:hi]\n    description \"Greets the user\"\n    long_description \"\"\"\n    Gives a nice a warm greeting to whoever would listen\n    \"\"\"\n\n    argument :name\n    option :from, help: \"the sender of hello\"\n\n    run context do\n      if context.verbose \u003e 0 do\n        IO.puts(\"Running hello command\")\n      end\n      if from = context[:from] do\n        IO.write(\"#{from} says: \")\n      end\n      IO.puts(\"Hello #{context.name}!\")\n    end\n  end\nend\n\nExCLI.run!(MyApp.SampleCLI)\n```\n\nWhich can be used in the following way.\n\n```\nsample_cli hello -vv world --from me\n```\n\nor using the command's alias:\n\n```\nsample_cli hi -vv world --from me\n```\n\nThe application usage will be shown if the parsing fails. The above example would show:\n\n```\nusage: mycli [--verbose] \u003ccommand\u003e [\u003cargs\u003e]\n\nCommands\n   hello   Greets the user\n```\n\n## `escript` and `mix` integration\n\nYou can very easily generate a mix task or an escript using `ExCLI`\n\n### `escript`\n\nPass `escript: true` to the `use ExCLI.DSL` and set the module as `escript` `:main_module`:\n\n```elixir\n# lib/my_escript_cli.ex\ndefmodule MyEscriptCLI do\n  use ExCLI.DSL, escript: true\nend\n\n# mix.exs\ndefmodule MyApp.Mixfile do\n  def project do\n    [app: :my_app,\n     escript: [main_module: MyEscriptCLI]]\n  end\nend\n```\n\n### `mix` integration\n\nPass `mix_task: TASK_NAME` to the `use ExCLI.DSL`.\n\n```elixir\n# lib/my_cli_task.ex\ndefmodule MyCLITask do\n  use ExCLI.DSL, mix_task: :great_task\nend\n```\n\nYou can then run\n\n```\nmix great_task\n```\n\nand get nicely formatted help with\n\n```\nmix help great_task\n```\n\n\n## Documentation\n\nCheck out the [documentation][1] for more information.\n\n## Roadmap\n\n  * [x] Command parser\n\n    The command parser is now working and should be enough for a good number of tasks.\n\n  * [x] Integration with `escript` and `mix`\n\n    `ExCLI.DSL` can generate a module compatible with `escript.build` as well as a `mix` task.\n\n  * [x] Usage generation\n\n    A nicely formatted usage is generated from the DSL.\n\n  * [ ] Help command\n\n    Then the goal will be to add a `help` command which can be used as `app help command` to show help about `command`.\n\n  * [ ] Command parser improvements\n\n    When the usage and help parts are done, there are a few improvements that will be nice to have in the command parser:\n\n      * [x] the ability to set a default command\n      * [ ] the ability to easily delegate a command to another module\n      * [x] command aliases\n\n  * [ ] Man page generation\n\n    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.\n\n## Contributing\n\nContributions are very welcome, feel free to open an issue or a PR.\n\nI am also looking for a better name, ideas are welcome!\n\n[1]: https://hexdocs.pm/ex_cli/api-reference.html\n[2]: https://cloud.githubusercontent.com/assets/1436271/15265160/fddba4ea-19b8-11e6-9f48-1ac3be7e839c.gif\n","funding_links":[],"categories":["Elixir"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanhper%2Fex_cli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdanhper%2Fex_cli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanhper%2Fex_cli/lists"}