{"id":19933028,"url":"https://github.com/kontena/clamp-completer","last_synced_at":"2025-06-10T22:03:12.551Z","repository":{"id":33974829,"uuid":"164820790","full_name":"kontena/clamp-completer","owner":"kontena","description":"Automatically generate shell autocompletion scripts for clamp based ruby CLI tools","archived":false,"fork":false,"pushed_at":"2020-08-19T10:02:24.000Z","size":22,"stargazers_count":9,"open_issues_count":5,"forks_count":4,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-05-21T15:20:00.301Z","etag":null,"topics":["autocomplete","bash","clamp","cli","gem","ruby","rubygem","shell","zsh"],"latest_commit_sha":null,"homepage":"","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kontena.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}},"created_at":"2019-01-09T08:25:47.000Z","updated_at":"2023-12-01T07:31:42.000Z","dependencies_parsed_at":"2022-08-09T03:30:25.479Z","dependency_job_id":null,"html_url":"https://github.com/kontena/clamp-completer","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/kontena%2Fclamp-completer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kontena%2Fclamp-completer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kontena%2Fclamp-completer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kontena%2Fclamp-completer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kontena","download_url":"https://codeload.github.com/kontena/clamp-completer/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kontena%2Fclamp-completer/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259159621,"owners_count":22814490,"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":["autocomplete","bash","clamp","cli","gem","ruby","rubygem","shell","zsh"],"created_at":"2024-11-12T23:12:28.889Z","updated_at":"2025-06-10T22:03:12.499Z","avatar_url":"https://github.com/kontena.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.org/kontena/clamp-completer.svg?branch=master)](https://travis-ci.org/kontena/clamp-completer)\n[![Gem Version](https://badge.fury.io/rb/clamp-completer.svg)](https://badge.fury.io/rb/clamp-completer)\n\n# Clamp::Completer\n\nAutomatically generate shell auto-completion scripts for Ruby command-line tools built using the [clamp](https://github.com/mdub/clamp) gem.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'clamp-completer'\n```\n\nOr install it yourself as:\n\n```\n$ gem install clamp-completer\n```\n\n## Usage\n\nRequire the `clamp/completer` and in your application's root command, add a subcommand:\n\n```ruby\nrequire 'clamp/completer'\n\nClamp do\n  subcommand \"complete\", \"shell autocompletions\", Clamp::Completer.new(self)\nend\n```\n\nThis will add a `complete` subcommand:\n\n```\n$ your_app complete zsh\n$ your_app complete bash\n```\n\nYou can redirect the output to a static file or load the output directly into the running environment:\n\n```\n# zsh / bash:\n$ source \u003c(your_app complete)\n# or for the macOs preinstalled bash version:\n$ source /dev/stdin \u003c\u003c\u003c\"$(your_app complete bash)\"\n```\n\n### Customizing completions\n\nCurrently, subcommand completions and flag-type options defined through `option '--debug', :flag, 'enable debug'` should work correctly out-of-the-box. For options that take parameters,\nsuch as file paths or a predefined set of words, you can define methods on your command classes that will be used to determine how the values should be completed:\n\n```ruby\nClamp do\n  option '--config', 'YAML_FILE', \"configuration YAML file path\"\n\n  def complete_yaml_file # name derived from the YAML_FILE argument description\n    { glob: '*.yml' }\n  end\nend\n```\n\n```ruby\nClamp do\n  option '--role', 'ROLE_NAME', \"node role\"\n\n  def complete_role # name derived from the attribute name\n    \"master worker\" # will add \"master\" and \"worker\" as completion responses when you do: your_app --role \u003ctab\u003e\n  end\nend\n```\n\n#### Completion method response types\n\n##### String\n\nA space separated string of possible values for the option\n\n##### Symbol\n\nCurrently known symbols:\n\n* `:dirs` will complete directory names\n* `:files` will complete file names\n* `:hosts` will complete known host names\n\n##### Hash\n\nMuch like the Symbols, but returned in Hash format to enable passing options:\n\n* `{ glob: '*.yml' }` will complete files endinging with `.yml`\n* `{ command: 'cut -d':' -f1 /etc/passwd' }` will run a command to get completion candidates, in this case the usernames from `/etc/password`\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/clamp-completer.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkontena%2Fclamp-completer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkontena%2Fclamp-completer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkontena%2Fclamp-completer/lists"}