{"id":13507602,"url":"https://github.com/bennyhallett/anubis","last_synced_at":"2025-03-30T09:32:59.311Z","repository":{"id":20877011,"uuid":"24164118","full_name":"BennyHallett/anubis","owner":"BennyHallett","description":"Command Line application framework for Elixir","archived":true,"fork":false,"pushed_at":"2018-02-12T19:48:34.000Z","size":17,"stargazers_count":130,"open_issues_count":3,"forks_count":5,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-03-16T04:12:56.932Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/BennyHallett.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":"2014-09-17T22:04:57.000Z","updated_at":"2024-01-18T11:40:53.000Z","dependencies_parsed_at":"2022-08-30T11:32:15.766Z","dependency_job_id":null,"html_url":"https://github.com/BennyHallett/anubis","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BennyHallett%2Fanubis","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BennyHallett%2Fanubis/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BennyHallett%2Fanubis/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BennyHallett%2Fanubis/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BennyHallett","download_url":"https://codeload.github.com/BennyHallett/anubis/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246301963,"owners_count":20755512,"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":[],"created_at":"2024-08-01T02:00:36.839Z","updated_at":"2025-03-30T09:32:59.061Z","avatar_url":"https://github.com/BennyHallett.png","language":"Elixir","funding_links":[],"categories":["Command Line Applications"],"sub_categories":[],"readme":"Anubis\n======\n\n[![Package](http://img.shields.io/hexpm/v/anubis.svg)](https://hex.pm/packages/anubis)\n\nAnubis is a library for creating command line applications in Elixir.\n\n## Features\n\n### Simple command creation\n\nAnubis allows you to create command line applications with multiple commands (like [git](http://git-scm.com/)), without needing to define multiple mix tasks. This can be useful when exporting your command line application as an escript.\n\nAs you can see in the example, just call the `command` macro, passing in an atom for the command name, a description of that command, and the function that should be invoked when that command is run. Some restrictions apply to these functions. Firstly, it must be a named function. Also, the command should accept 1 parameter: the list of arguments after the command. In our example below, if we call\n\n    $ mix example init some params\n\nthen the `Named.Function.init` function will be invoked with the arguments `[\"some\", \"params\"]`.\n\nThe named function must accept a single tuple as a parameter. This tuple will have three entries, `{arguments, options, runtime_configuration}`.\n\n### Simple option definition\n\nLike most command line applications, yours may need to be configurable. This may include things like which credentials to use when connecting to another resource, or which file to load from disk.\n\nAnubis makes defining which switches are valid and what their types are quite simple, as you can see in the example file below. Valid types include:\n\n* :string\n* :integer\n* :boolean\n* :float\n\n*Be warned*: Anubis uses strict parsing, so any options that are passed in that haven't been defined will be ignored, and potentially have their value consumed as an argument.\n\nNext release will include warnings when this occurs.\n\n### Help out of the box\n\nOnce you've defined your commands, Anubis will automatically generate a help command for you, which lists out the available commands and their descriptions, along with what switches are available.\n\n    $ mix example help\n\nYour help can include a banner, describing the application and it's use. Use the `banner` macro (as in the example below) to set it up.\n\n### Runtime configuration in a snap\n\nSome command line apps need more powerful configuration than just switches. Where switches can be used to control a single invocation of the application, maybe you want to configure your environment to run a certain way every time.\n\nThis is where the RC file comes in.\n\nWe define our runtime configuration by using the `rc_file` macro, which takes a single dictionary as its parameter. This specifies the default contents of the file, but once it's created we can modify it to include whatever we want.\n\n\u003e *NOTE:* Anubis doesn't support nested structures in the rc file. Each entry in the dictionary should be either a `String`, `Integer`, `Float`, or `Boolean`. Anubis will respect the types included in the dictionary, and will load them out the same way they were stored.\n\nBy using the `rc_file` macro, we get an extra command created for us: `initrc`. This command will write out an RC file to the current user's home directory, based on the module name given. It will strip off `Mix.Tasks`, so our rc file in the example below would be `~/.example.rc`\n\n## An example\n\n```elixir\ndefmodule Mix.Tasks.Example\n  use Mix.Task\n  use Anubis\n\n  banner \"\"\"\n  This is the example task.\n\n  Use it like:\n      $ mix example \u003ccommand\u003e \u003cargs\u003e\n  \"\"\"\n\n  rc_file %{\n    username: \"user\",\n    password: \"p4$$w0rd\",\n    people: 10\n  }\n\n  option :file,  :string,   \"The file to be loaded.\"\n  option :procs: :integer,  \"The number of concurrent processes to run\" \n\n  command :init, \"Initialize the project.\", Named.Function.init\n  command :send, \"Send me a small letter.\", Named.Function.send\n  command :list, \"List all of the things.\", Named.Function.list\n\n  parse\nend\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbennyhallett%2Fanubis","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbennyhallett%2Fanubis","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbennyhallett%2Fanubis/lists"}