{"id":20784915,"url":"https://github.com/emad-elsaid/command_tree","last_synced_at":"2025-06-16T09:09:09.088Z","repository":{"id":56843724,"uuid":"149740346","full_name":"emad-elsaid/command_tree","owner":"emad-elsaid","description":"Builds trees of commands for the terminal, each node is either a group of commands or the command itself, every node is associated with a character to access it.","archived":false,"fork":false,"pushed_at":"2020-08-04T08:13:36.000Z","size":14,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-05T14:53:59.710Z","etag":null,"topics":["cli","ruby","terminal"],"latest_commit_sha":null,"homepage":null,"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/emad-elsaid.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":null,"security":null,"support":null}},"created_at":"2018-09-21T09:18:58.000Z","updated_at":"2020-08-04T08:13:29.000Z","dependencies_parsed_at":"2022-09-05T14:50:21.786Z","dependency_job_id":null,"html_url":"https://github.com/emad-elsaid/command_tree","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/emad-elsaid/command_tree","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emad-elsaid%2Fcommand_tree","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emad-elsaid%2Fcommand_tree/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emad-elsaid%2Fcommand_tree/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emad-elsaid%2Fcommand_tree/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/emad-elsaid","download_url":"https://codeload.github.com/emad-elsaid/command_tree/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/emad-elsaid%2Fcommand_tree/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260131556,"owners_count":22963448,"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","ruby","terminal"],"created_at":"2024-11-17T14:34:29.662Z","updated_at":"2025-06-16T09:09:08.971Z","avatar_url":"https://github.com/emad-elsaid.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CommandTree [![Gem Version](https://badge.fury.io/rb/command_tree.svg)](https://badge.fury.io/rb/command_tree)\n\nBuilds trees of commands for the terminal, each node is either a group of commands or the command itself, every node is associated with a character to access it.\n\n[![asciicast](https://asciinema.org/a/202202.png)](https://asciinema.org/a/202202)\nThe previous Asciinema script is here: https://gist.github.com/emad-elsaid/b259894caa9a78863b582ecc7a31811a\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'command_tree'\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install command_tree\n\n## Usage\n\nYou start by creating a new tree\n\n```ruby\nt = CommandTree::Tree.new\n```\n\nThen you register a command category (a node that contains a group of commands)\n\n```ruby\nt.register 'a', 'Applications' # associate the character 'a' to a category called 'applications'\n```\n\nThen register commands inside that prefix\n```ruby\nt.register 'ag','Google Chrome' do\n  system 'google-chrome-stable'\nend\n```\nthe previous block will be assigned to 'g' inside 'a' which is the application's prefix, so you can execute it with 'ag' when you run that tree in terminal.\n\nTo run the tree call `#show`\n```ruby\nt.show\n```\n\nit will print the toplevel categories and commands and wait for you to press a character to execute the command or print sub commands of a category node.\n\nwhen the tree reachs a leaf it'll exit, if a command is the leaf it will execute it and exit the tree giving your code the control again.\n\n\nThere is another way to define a group of commands in a nested way using `Tree#group` method as follows\n\n```ruby\nt = CommandTree::Tree.new\nt.group 'a', 'Applications' do |g|\n  g.register 'g','Google Chrome' do\n    system 'google-chrome-stable'\n  end\nend\nt.show\n```\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/emad-elsaid/command_tree.\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Femad-elsaid%2Fcommand_tree","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Femad-elsaid%2Fcommand_tree","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Femad-elsaid%2Fcommand_tree/lists"}