{"id":22981028,"url":"https://github.com/rubyworks/clik","last_synced_at":"2025-08-13T17:33:47.909Z","repository":{"id":7311677,"uuid":"8629550","full_name":"rubyworks/clik","owner":"rubyworks","description":"Kernel#cli","archived":false,"fork":false,"pushed_at":"2014-12-27T17:02:55.000Z","size":211,"stargazers_count":97,"open_issues_count":0,"forks_count":1,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-11-15T18:09:13.716Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rubyworks.png","metadata":{"files":{"readme":"README.md","changelog":"HISTORY.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-03-07T14:51:35.000Z","updated_at":"2024-06-01T01:41:20.000Z","dependencies_parsed_at":"2022-09-10T03:10:39.687Z","dependency_job_id":null,"html_url":"https://github.com/rubyworks/clik","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubyworks%2Fclik","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubyworks%2Fclik/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubyworks%2Fclik/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubyworks%2Fclik/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rubyworks","download_url":"https://codeload.github.com/rubyworks/clik/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":229773540,"owners_count":18122031,"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-12-15T01:46:45.988Z","updated_at":"2024-12-15T01:46:46.520Z","avatar_url":"https://github.com/rubyworks.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CLI.K\n\n[Website](http://github.com/rubyworks/clik) /\n[Documentation](http://rubydoc.info/gems/clik/frames) /\n[Report Issue](http://github.com/rubyworks/clik/issues) /\n[Source Code](http://github.com/rubyworks/clik) \u0026nbsp; \u0026nbsp;\n[![Flattr Me](http://api.flattr.com/button/flattr-badge-large.png)](http://flattr.com/thing/324911/Rubyworks-Ruby-Development-Fund)\n\n\n## About\n\nCLI.K stands for Command Line Interface in the Kernel. It provides a very \nsimple `cli` method for parsing command line options.\n\n\n## Status\n\n[![Gem Version](https://badge.fury.io/rb/clik.png)](http://badge.fury.io/rb/clik)\n[![Build Status](https://travis-ci.org/rubyworks/clik.png)](https://travis-ci.org/rubyworks/clik)\n\n\n## Usage\n\n### They call it \"K.I.S.S.\"\n\nUsage is very straightforward, although it might look a little odd at first\nglance:\n\n```ruby\n  require 'clik'\n\n  cli '-f --file'  =\u003e lambda{ |f| @file = f },\n      '-d --debug' =\u003e lambda{ $DEBUG = true },\n      '-h --help'  =\u003e lambda{ show_help }\n```\n\nThere's very little to it really. The `cli` command simply maps command\nline options to procedures which are used to process them. That's it.\n\nIn our example, notice that `-f` and `--file` are easily defined as \nsynonymous options. Simple. Then notice that the `-f/--file` option's\nprocedure takes an argument, so the command line option takes an argument \nas well. Again simple.\n\nThe cli method has a few additional niceties. It can handle run-on flags,\ni.e. `-abc` is the same as `-a -b -c`. And you can pass it an alternate\nset of arguments to parse, as the first argument, to use something other \nthan the default `ARGV`.\n\n```ruby\n  argv = ['--testing']\n\n  cli argv,\n    ...\n```\n\n### You need help, no you really don't\n\nAt this point, you might be wondering about help output. Clearly there are\nno descriptions given in our example. Well, guess what! It's really easy\nto print something out yourself. In fact, if you really want to *do it right*,\ncreate a manpage with [ronn](git://github.com/rtomayko/ronn.git) or\n[md2man](https://github.com/sunaku/md2man), and impress your friends.\nIt's a much better approach then jamming all that verbiage into the command\nline options parser code.\n\n### Ask and you shell receive\n\nIn addition to #cli, CLI.K provides the #ask method. This is a very simple\ncommand line query method.\n\n    ans = ask \"Are you nice? [Y/n]\"\n\nOther Ruby libraries have their own take on the #ask method, and this very\nsimple implementation can just as soon be overridden. No biggy. But it's nice\nto have for simple use cases.\n\n\n## Acknowledgments\n\nWe have to give credit where credit is due. This interface is the great \nachievement of Michel Martens, who created the original [Clap](https://github.com/soveran/clap)\nlibrary from which CLI.K evolved. Mr. Martens deserves high praise for this\ndesign. It's not easy to realize that this level of simplicity is all one\nreally needs! Thank you, Michel!\n\n\n## Copyrights \u0026 License\n\nCLI.K is copyrighted open-source software.\n\n    Copyright (c) 2013 Rubyworks\n\nCLI.K is base on Michel Marten's Clap library.\n\n    Copyright (c) 2010 Michel Martens\n\nSee LICENSE.txt and NOTICE.txt files for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frubyworks%2Fclik","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frubyworks%2Fclik","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frubyworks%2Fclik/lists"}