{"id":13482539,"url":"https://github.com/mosop/cli","last_synced_at":"2026-01-17T03:38:08.077Z","repository":{"id":89452399,"uuid":"60625000","full_name":"mosop/cli","owner":"mosop","description":"Yet another Crystal library for building command-line interface applications.","archived":false,"fork":false,"pushed_at":"2020-06-27T03:55:42.000Z","size":228,"stargazers_count":101,"open_issues_count":4,"forks_count":8,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-08-01T17:32:31.065Z","etag":null,"topics":["cli","crystal-library"],"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/mosop.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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}},"created_at":"2016-06-07T15:30:53.000Z","updated_at":"2024-07-19T06:24:37.000Z","dependencies_parsed_at":"2023-03-13T18:09:41.912Z","dependency_job_id":null,"html_url":"https://github.com/mosop/cli","commit_stats":null,"previous_names":[],"tags_count":53,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mosop%2Fcli","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mosop%2Fcli/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mosop%2Fcli/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mosop%2Fcli/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mosop","download_url":"https://codeload.github.com/mosop/cli/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":222262364,"owners_count":16957565,"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","crystal-library"],"created_at":"2024-07-31T17:01:03.055Z","updated_at":"2026-01-17T03:38:08.067Z","avatar_url":"https://github.com/mosop.png","language":"Crystal","readme":"# Crystal CLI\n\nYet another Crystal library for building command-line interface applications.\n\n[![CircleCI](https://circleci.com/gh/mosop/cli.svg?style=shield)](https://circleci.com/gh/mosop/cli)\n\n## Installation\n\nAdd this to your application's `shard.yml`:\n\n```yaml\ndependencies:\n  cli:\n    github: mosop/cli\n```\n\n\u003ca name=\"code_samples\"\u003e\u003c/a\u003e\n\n## Code Samples\n\n### Option Parser\n\n```crystal\nclass Hello \u003c Cli::Command\n  class Options\n    bool \"--bye\"\n    arg \"to\"\n  end\n\n  def run\n    if args.bye?\n      print \"Goodbye\"\n    else\n      print \"Hello\"\n    end\n    puts \" #{args.to}!\"\n  end\nend\n\nHello.run %w(world) # prints \"Hello, world!\"\nHello.run %w(--bye world) # prints \"Goodbye, world!\"\n```\n\n### Subcommand\n\n```crystal\nclass Polygon \u003c Cli::Supercommand\n  command \"triangle\", default: true\n\n  class Triangle \u003c Cli::Command\n    def run\n      puts 3\n    end\n  end\n\n  class Square \u003c Cli::Command\n    def run\n      puts 4\n    end\n  end\n\n  class Hexagon \u003c Cli::Command\n    def run\n      puts 6\n    end\n  end\nend\n\nPolygon.run %w(triangle) # prints \"3\"\nPolygon.run %w(square)   # prints \"4\"\nPolygon.run %w(hexagon)  # prints \"6\"\nPolygon.run %w()         # prints \"3\"\n```\n\n### Replacing\n\n```crystal\nclass New \u003c Cli::Command\n  def run\n    puts \"new!\"\n  end\nend\n\nclass Obsolete \u003c Cli::Command\n  replacer_command New\nend\n\nObsolete.run # prints \"new!\"\n```\n\n### Inheritance\n\n```crystal\nabstract class Role \u003c Cli::Command\n  class Options\n    string \"--name\"\n  end\nend\n\nclass Chase \u003c Cli::Supercommand\n  class Mouse \u003c Role\n    def run\n      puts \"#{options.name} runs away.\"\n    end\n  end\n\n  class Cat \u003c Role\n    def run\n      puts \"#{options.name} runs into a wall.\"\n    end\n  end\nend\n\nChase.run %w(mouse --name Jerry) # prints \"Jerry runs away.\"\nChase.run %w(cat --name Tom)     # prints \"Tom runs into a wall.\"\n```\n\n### Help\n\n```crystal\nclass Call \u003c Cli::Command\n  class Help\n    header \"Receives an ancient message.\"\n    footer \"(C) 20XX mosop\"\n  end\n\n  class Options\n    arg \"message\", desc: \"your message to call them\", required: true\n    bool \"-w\", not: \"-W\", desc: \"wait for response\", default: true\n    help\n  end\nend\n\nCall.run %w(--help)\n```\n\nOutput:\n\n```\ncall [OPTIONS] MESSAGE\n\nReceives an ancient message.\n\nArguments:\n  MESSAGE (required)  your message to call them\n\nOptions:\n  -w          wait for response\n              (default: true)\n  -W          disable -w\n  -h, --help  show this help\n\n(C) 20XX mosop\n```\n\n### Versioning\n\n```crystal\nclass Command \u003c Cli::Supercommand\n  version \"1.0.0\"\n\n  class Options\n    version\n  end\nend\n\nCommand.run %w(-v) # prints 1.0.0\n```\n\n### Shell Completion\n\n```crystal\nclass TicketToRide \u003c Cli::Command\n  class Options\n    string \"--by\", any_of: %w(train plane taxi)\n    arg \"for\", any_of: %w(kyoto kanazawa kamakura)\n  end\nend\n\nputs TicketToRide.generate_bash_completion\n# or\nputs TicketToRide.generate_zsh_completion\n```\n\n## Usage\n\n```crystal\nrequire \"cli\"\n```\n\nand see:\n\n* [Code Samples](#code_samples)\n* [Wiki](https://github.com/mosop/cli/wiki)\n* [API Document](http://mosop.me/cli/Cli.html)\n\n## Want to Do\n\n- Application-Level Logger\n- I18n\n\n## Release Notes\n\nSee [Releases](https://github.com/mosop/cli/releases).\n","funding_links":[],"categories":["CLI Builders","\u003ca name=\"Crystal\"\u003e\u003c/a\u003eCrystal","Cli Builders"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmosop%2Fcli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmosop%2Fcli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmosop%2Fcli/lists"}