{"id":20237750,"url":"https://github.com/ragmaanir/kommando","last_synced_at":"2025-06-12T14:34:45.935Z","repository":{"id":136218023,"uuid":"459162903","full_name":"Ragmaanir/kommando","owner":"Ragmaanir","description":"Define CLI commands in crystal","archived":false,"fork":false,"pushed_at":"2024-02-25T17:53:27.000Z","size":62,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-03T14:47:27.044Z","etag":null,"topics":["cli","command-line","crystal"],"latest_commit_sha":null,"homepage":"","language":"Crystal","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/Ragmaanir.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-02-14T12:57:53.000Z","updated_at":"2024-07-02T05:05:06.000Z","dependencies_parsed_at":null,"dependency_job_id":"6ef9449d-daf1-48f8-b1bb-6ee97e2d1ceb","html_url":"https://github.com/Ragmaanir/kommando","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/Ragmaanir/kommando","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ragmaanir%2Fkommando","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ragmaanir%2Fkommando/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ragmaanir%2Fkommando/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ragmaanir%2Fkommando/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Ragmaanir","download_url":"https://codeload.github.com/Ragmaanir/kommando/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ragmaanir%2Fkommando/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259482963,"owners_count":22864857,"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","command-line","crystal"],"created_at":"2024-11-14T08:28:41.087Z","updated_at":"2025-06-12T14:34:45.892Z","avatar_url":"https://github.com/Ragmaanir.png","language":"Crystal","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Kommando [![Crystal CI](https://github.com/Ragmaanir/kommando/actions/workflows/crystal.yml/badge.svg)](https://github.com/Ragmaanir/kommando/actions/workflows/crystal.yml)\n\n### Version 0.1.2\n\nKommando is a library that helps you build small and large command line interfaces in crystal.\n\n## Installation\n\nAdd this to your application's `shard.yml`:\n\n```yaml\ndependencies:\n  kommando:\n    github: ragmaanir/kommando\n```\n\n## Features\n\n- positional arguments (like in `crystal init app MyApp`)\n- short and long options (like `cli new MyProject --dry -v --permissions=644 --repo=github -l=MIT`)\n- validation and type conversion of arguments\n- auto-generated documentation\n- namespaces/subcommands like `cli create user Toby`\n\n## Rationale\n\n**Why classes for commands and not methods**\n\nClasses can define helper methods that are scoped to the command. And the helper methods have access to all options of the command.\n\n\n## Usage\n\n### Commands\n\n```crystal\nrecord(User, name : String, age : Int32, height : Int32?, nickname : String?)\n\nUSERS = [] of User\n\nclass Create\n  include Kommando::Command\n  option(:height, Int32, \"\", validate: -\u003e(v : Int32) { (100..250).includes?(v) })\n  option(:nickname, String, \"\", format: /\\A[a-zA-Z]+\\z/)\n\n  option(:dead, Bool, \"Whether the person is dead\", default: false)\n\n  arg(:name, String)\n  arg(:age, Int32)\n\n  def call\n    USERS \u003c\u003c User.new(name, age, @height, @nickname)\n  end\nend\n\ntest \"create user with options\" do\n  user = User.new(\"Christian\", 55, 175, \"Chris\")\n\n  Create.call([\n    \"-height=#{user.height}\",\n    \"-nickname=#{user.nickname}\",\n    user.name, user.age.to_s,\n  ])\n\n  assert USERS == [user]\nend\n\n```\n\n### Namespaces\n\n```crystal\nrequire \"kommando\"\n\nclass Create\n  include Kommando::Command\n\n  def call\n  end\nend\n\nclass Migrate\n  include Kommando::Command\n\n  def call\n  end\nend\n\ntest do\n  root = Kommando::Namespace.root do\n    commands Create\n\n    namespace(\"db\") do\n      commands Create, Migrate\n    end\n  end\n\n  assert root.commands.keys == [\"create\"]\n  assert root.namespaces.keys == [\"db\"]\n\n  root.run([\"db\", \"create\"])\nend\n\n```\n\n## Contributing\n\n1. Fork it (https://github.com/ragmaanir/kommando/fork)\n2. Create your feature branch (git checkout -b my-new-feature)\n3. Commit your changes (git commit -am 'Add some feature')\n4. Push to the branch (git push origin my-new-feature)\n5. Create a new Pull Request\n\n## Contributors\n\n- [ragmaanir](https://github.com/ragmaanir) ragmaanir - creator, maintainer\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fragmaanir%2Fkommando","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fragmaanir%2Fkommando","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fragmaanir%2Fkommando/lists"}