{"id":13726734,"url":"https://github.com/Shopify/cli-ui","last_synced_at":"2025-05-07T22:30:30.109Z","repository":{"id":21478959,"uuid":"92980181","full_name":"Shopify/cli-ui","owner":"Shopify","description":"CLI tooling framework with simple interactive widgets","archived":false,"fork":false,"pushed_at":"2025-04-14T11:29:56.000Z","size":1295,"stargazers_count":1064,"open_issues_count":16,"forks_count":55,"subscribers_count":423,"default_branch":"main","last_synced_at":"2025-04-30T23:55:26.847Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Ruby","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/Shopify.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2017-05-31T19:15:08.000Z","updated_at":"2025-04-18T13:55:58.000Z","dependencies_parsed_at":"2023-01-16T21:45:11.013Z","dependency_job_id":"b14e8841-cc97-4e97-9db7-59c07a28d704","html_url":"https://github.com/Shopify/cli-ui","commit_stats":{"total_commits":671,"total_committers":45,"mean_commits":"14.911111111111111","dds":0.6706408345752608,"last_synced_commit":"b252740353d6ac789ca48d110e8ccbec4b6fcf30"},"previous_names":["shopify/dev-ui"],"tags_count":25,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Shopify%2Fcli-ui","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Shopify%2Fcli-ui/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Shopify%2Fcli-ui/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Shopify%2Fcli-ui/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Shopify","download_url":"https://codeload.github.com/Shopify/cli-ui/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252965069,"owners_count":21832817,"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-03T01:03:18.384Z","updated_at":"2025-05-07T22:30:29.515Z","avatar_url":"https://github.com/Shopify.png","language":"Ruby","readme":"CLI UI\n---\n\nCLI UI is a small framework for generating nice command-line user interfaces\n\n- [Master Documentation](http://www.rubydoc.info/github/Shopify/cli-ui/main/CLI/UI)\n- [Documentation of the Rubygems version](http://www.rubydoc.info/gems/cli-ui/)\n- [Rubygems](https://rubygems.org/gems/cli-ui)\n\n## Installation\n\n```bash\ngem install cli-ui\n```\n\nor add the following to your Gemfile:\n\n```ruby\ngem 'cli-ui'\n```\n\nIn your code, simply add a `require 'cli/ui'`. Most options assume `CLI::UI::StdoutRouter.enable` has been called.\n\n## Features\n\nThis may not be an exhaustive list. Please check our [documentation](http://www.rubydoc.info/github/Shopify/cli-ui/main/CLI/UI) for more information.\n\n---\n\n### Nested framing\nTo handle content flow (see example below)\n\n```ruby\nCLI::UI::StdoutRouter.enable\nCLI::UI::Frame.open('Frame 1') do\n  CLI::UI::Frame.open('Frame 2') { puts \"inside frame 2\" }\n  puts \"inside frame 1\"\nend\n```\n\n![Nested Framing](https://user-images.githubusercontent.com/3074765/33799861-cb5dcb5c-dd01-11e7-977e-6fad38cee08c.png)\n\n---\n\n### Interactive Prompts\nPrompt user with options and ask them to choose. Can answer using arrow keys, vim bindings (`j`/`k`), or numbers  (or y/n for yes/no questions).\n\nFor large numbers of options, using `e`, `:`, or `G` will toggle \"line select\" mode which allows numbers greater than 9 to be typed and\n`f` or `/` will allow the user to filter options using a free-form text input.\n\n```ruby\nCLI::UI.ask('What language/framework do you use?', options: %w(rails go ruby python))\n```\n\nTo set the color of instruction text:\n```ruby\nCLI::UI::Prompt.instructions_color = CLI::UI::Color::GRAY\n```\n\nCan also assign callbacks to each option\n\n```ruby\nCLI::UI::Prompt.ask('What language/framework do you use?') do |handler|\n  handler.option('rails')  { |selection| selection }\n  handler.option('go')     { |selection| selection }\n  handler.option('ruby')   { |selection| selection }\n  handler.option('python') { |selection| selection }\nend\n```\n\n* Note that the two examples provided above are identical in functionality\n\n![Interactive Prompt](https://user-images.githubusercontent.com/3074765/33797984-0ebb5e64-dcdf-11e7-9e7e-7204f279cece.gif)\n\n---\n\n### Free form text prompts\n\n```ruby\nCLI::UI.ask('Is CLI UI Awesome?', default: 'It is great!')\n```\n\n  ![Free form text prompt](https://user-images.githubusercontent.com/3074765/33799822-47f23302-dd01-11e7-82f3-9072a5a5f611.png)\n\n---\n\n### Spinner groups\nHandle many multi-threaded processes while suppressing output unless there is an issue. Can update title to show state.\n\n```ruby\nCLI::UI::SpinGroup.new do |spin_group|\n  spin_group.add('Title')   { |spinner| sleep 3.0 }\n  spin_group.add('Title 2') { |spinner| sleep 3.0; spinner.update_title('New Title'); sleep 3.0 }\nend\n```\n\n![Spinner Group](https://user-images.githubusercontent.com/3074765/33798295-d94fd822-dce3-11e7-819b-43e5502d490e.gif)\n\n---\n\n### Text Color formatting\ne.g. `{{red:Red}} {{green:Green}}`\n\n```ruby\nputs CLI::UI.fmt \"{{red:Red}} {{green:Green}}\"\n```\n\n![Text Format](https://user-images.githubusercontent.com/3074765/33799827-6d0721a2-dd01-11e7-9ab5-c3d455264afe.png)\n\n---\n\n### Symbol/Glyph Formatting\ne.g. `{{*}}` =\u003e a yellow ⭑\n\n```ruby\nputs CLI::UI.fmt \"{{*}} {{v}} {{?}} {{x}}\"\n```\n\n![Symbol Formatting](https://user-images.githubusercontent.com/3074765/33799847-9ec03fd0-dd01-11e7-93f7-5f5cc540e61e.png)\n\n---\n\n### Status Widget\n\n```ruby\nCLI::UI::Spinner.spin(\"building packages: {{@widget/status:1:2:3:4}}\") do |spinner|\n  # spinner.update_title(...)\n  sleep(3)\nend\n```\n\n![Status Widget](https://user-images.githubusercontent.com/1284/61405142-11042580-a8a7-11e9-9885-46ba44c46358.gif)\n\n---\n\n### Progress Bar\n\nShow progress of a process or operation.\n\n```ruby\nCLI::UI::Progress.progress do |bar|\n  100.times do\n    bar.tick\n  end\nend\n```\n\n![Progress Bar](https://user-images.githubusercontent.com/3074765/33799794-cc4c940e-dd00-11e7-9bdc-90f77ec9167c.gif)\n\n---\n\n### Frame Styles\n\nModify the appearance of CLI::UI both globally and on an individual frame level.\n\nTo set the default style:\n\n```ruby\nCLI::UI.frame_style = :box\n```\n\nTo style an individual frame:\n\n```ruby\nCLI::UI.frame('New Style!', frame_style: :bracket) { puts \"It's pretty cool!\" }\n```\n\nThe default style - `:box` - is what has been used up until now.  The other style - `:bracket` - looks like this:\n\n```ruby\nCLI::UI.frame_style = :bracket\nCLI::UI::StdoutRouter.enable\nCLI::UI::Frame.open('Frame 1') do\n  CLI::UI::Frame.open('Frame 2') { puts \"inside frame 2\" }\n  puts \"inside frame 1\"\nend\n```\n\n![Frame Style](https://user-images.githubusercontent.com/315948/65287373-9a82de80-db08-11e9-94fb-20f4b7561c07.png)\n\n---\n\n## Sorbet\n\nWe make use of [Sorbet](https://sorbet.org/) in cli-ui. We provide stubs for Sorbet so that you can use this gem even\nif you aren't using Sorbet. We activate these stubs if `T` is undefined when the gem is loaded. For this reason, if you\nwould like to use this gem and your project _does_ use Sorbet, ensure you load Sorbet _before_ loading cli-ui.\n\n## Example Usage\n\nThe following code makes use of nested-framing, multi-threaded spinners, formatted text, and more.\n\n```ruby\nrequire 'cli/ui'\n\nCLI::UI::StdoutRouter.enable\n\nCLI::UI::Frame.open('{{*}} {{bold:a}}', color: :green) do\n  CLI::UI::Frame.open('{{i}} b', color: :magenta) do\n    CLI::UI::Frame.open('{{?}} c', color: :cyan) do\n      CLI::UI::SpinGroup.new do |sg|\n        sg.add('wow') do |spinner|\n          sleep(2.5)\n          spinner.update_title('second round!')\n          sleep (1.0)\n        end\n        sg.add('such spin') { sleep(1.6) }\n        sg.add('many glyph') { sleep(2.0) }\n      end\n    end\n  end\n  CLI::UI::Frame.divider('{{v}} lol')\n  puts CLI::UI.fmt '{{info:words}} {{red:oh no!}} {{green:success!}}'\n  CLI::UI::SpinGroup.new do |sg|\n    sg.add('more spins') { sleep(0.5) ; raise 'oh no' }\n  end\nend\n```\n\nOutput:\n\n![Example Output](https://user-images.githubusercontent.com/3074765/33797758-7a54c7cc-dcdb-11e7-918e-a47c9689f068.gif)\n\n## Development\n\n- Run tests using `bundle exec rake test`. All code should be tested.\n- No code, outside of development and tests needs, should use dependencies. This is a self contained library\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/Shopify/cli-ui.\n\n## License\n\nThe code is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).\n","funding_links":[],"categories":["Ruby"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FShopify%2Fcli-ui","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FShopify%2Fcli-ui","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FShopify%2Fcli-ui/lists"}