{"id":20761705,"url":"https://github.com/s0rg/compflag","last_synced_at":"2025-06-12T10:07:38.383Z","repository":{"id":62867555,"uuid":"562357373","full_name":"s0rg/compflag","owner":"s0rg","description":"Auto-completion for stdlib flag items","archived":false,"fork":false,"pushed_at":"2025-04-25T12:12:43.000Z","size":17,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-25T13:26:30.063Z","etag":null,"topics":["autocompletion","bash-completion","golang-library","shell","zsh-completion"],"latest_commit_sha":null,"homepage":"","language":"Go","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/s0rg.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":"2022-11-06T04:40:22.000Z","updated_at":"2025-04-25T12:11:56.000Z","dependencies_parsed_at":"2023-01-21T09:18:09.760Z","dependency_job_id":null,"html_url":"https://github.com/s0rg/compflag","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/s0rg%2Fcompflag","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/s0rg%2Fcompflag/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/s0rg%2Fcompflag/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/s0rg%2Fcompflag/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/s0rg","download_url":"https://codeload.github.com/s0rg/compflag/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251653233,"owners_count":21622090,"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":["autocompletion","bash-completion","golang-library","shell","zsh-completion"],"created_at":"2024-11-17T10:25:23.421Z","updated_at":"2025-04-30T06:27:12.492Z","avatar_url":"https://github.com/s0rg.png","language":"Go","readme":"[![PkgGoDev](https://pkg.go.dev/badge/github.com/s0rg/compflag)](https://pkg.go.dev/github.com/s0rg/compflag)\n[![License](https://img.shields.io/github/license/s0rg/compflag)](https://github.com/s0rg/compflag/blob/master/LICENSE)\n[![Go Version](https://img.shields.io/github/go-mod/go-version/s0rg/compflag)](go.mod)\n[![Tag](https://img.shields.io/github/v/tag/s0rg/compflag?sort=semver)](https://github.com/s0rg/compflag/tags)\n\n[![CI](https://github.com/s0rg/compflag/workflows/ci/badge.svg)](https://github.com/s0rg/compflag/actions?query=workflow%3Aci)\n[![Go Report Card](https://goreportcard.com/badge/github.com/s0rg/compflag)](https://goreportcard.com/report/github.com/s0rg/compflag)\n[![Maintainability](https://qlty.sh/badges/40c7eb9f-11aa-4fbd-bac9-0a674b89270b/maintainability.svg)](https://qlty.sh/gh/s0rg/projects/compflag)\n[![Code Coverage](https://qlty.sh/badges/40c7eb9f-11aa-4fbd-bac9-0a674b89270b/test_coverage.svg)](https://qlty.sh/gh/s0rg/projects/compflag)\n![Issues](https://img.shields.io/github/issues/s0rg/compflag)\n\n# compflag\n\nAuto-completion for stdlib flag items\n\n# usage\n\nyou got two options here:\n\n- Call compflag.Complete() somewhere before actual app logic, best point is right at the start:\n```go\n    package main\n\n    import (\n        \"os\"\n        \"flag\"\n\n        \"github.com/s0rg/compflag\"\n    )\n\n    func main() {\n        if compflag.Complete() {\n            os.Exit(0)\n        }\n\n        flag.Parse()\n\n        // other startup logic...\n    }\n```\n\n- Define trigger flag for completion:\n```go\n    package main\n\n    import (\n        \"os\"\n        \"flag\"\n\n        \"github.com/s0rg/compflag\"\n    )\n\n    func main() {\n        compflag.Var(\"complete\")\n\n        flag.Parse()\n\n        // other startup logic...\n    }\n\n```\n\nPlease note, that you need to exit app if any completion happened.\n\nBuild your app, put binary somewhere in your \"PATH\", then run:\n\n```bash\n    complete -C %your-binary-name% %your-binary-name%\n```\n\nif you prefer flag-triggered version:\n```bash\n    complete -C \"%your-binary-name% -%your-flag% bash\" %your-binary-name%\n```\n\nNow enter `%your-binary-name%`, and hit `TAB` twice )\n\n# shell compatability\n\nThis will work with any shell compatible with `complete` (bash and zsh are both good with it), for zsh you may need\nalso use `bashcompinit` in addition to `compinit`.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fs0rg%2Fcompflag","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fs0rg%2Fcompflag","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fs0rg%2Fcompflag/lists"}