{"id":15765585,"url":"https://github.com/posener/flag","last_synced_at":"2025-03-13T22:32:15.197Z","repository":{"id":57600645,"uuid":"91908472","full_name":"posener/flag","owner":"posener","description":"Like the flag package, but with bash completion support!","archived":false,"fork":false,"pushed_at":"2020-03-13T18:47:57.000Z","size":18,"stargazers_count":5,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-05T12:42:39.582Z","etag":null,"topics":["bash-completion","flag","go"],"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/posener.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":"2017-05-20T18:27:09.000Z","updated_at":"2019-01-28T15:57:01.000Z","dependencies_parsed_at":"2022-08-24T14:40:27.114Z","dependency_job_id":null,"html_url":"https://github.com/posener/flag","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/posener%2Fflag","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/posener%2Fflag/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/posener%2Fflag/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/posener%2Fflag/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/posener","download_url":"https://codeload.github.com/posener/flag/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221418301,"owners_count":16817076,"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":["bash-completion","flag","go"],"created_at":"2024-10-04T12:42:55.775Z","updated_at":"2024-10-25T10:40:32.161Z","avatar_url":"https://github.com/posener.png","language":"Go","readme":"# flag\n\n[![Build Status](https://travis-ci.org/posener/flag.svg?branch=master)](https://travis-ci.org/posener/flag)\n[![codecov](https://codecov.io/gh/posener/flag/branch/master/graph/badge.svg)](https://codecov.io/gh/posener/flag)\n[![GoDoc](https://godoc.org/github.com/posener/flag?status.svg)](http://godoc.org/github.com/posener/flag)\n[![Go Report Card](https://goreportcard.com/badge/github.com/posener/flag)](https://goreportcard.com/report/github.com/posener/flag)\n\nLike `flag`, but with bash completion support.\n\n## Features\n\n* Fully compatible with standard library `flag` package\n* Bash completions for flag names and flag values\n* Additional flag types provided:\n  * [`File`/`Dir`](./flag_path.go): file completion flag\n  * [`Bool`](./flag_bool.go): bool flag (that does not complete)\n  * [`Choice`](./flag_choice.go): choices flag\n  * [`StringCompleter`](./flag_completer.go): custom completions\n  * Any other value that implements the [`Completer`](./complete.go) interface.\n\n## Example\n\nHere is an [example](./example/example.go)\n\n## Usage\n\n```diff\nimport (\n-\t\"flag\"\n+\t\"github.com/posener/flag\"\n)\n\nvar (\n-\tfile = flag.String(\"file\", \"\", \"file value\")\n+\tfile = flag.File(\"file\", \"*.md\", \"\", \"file value\")\n-\tdir  = flag.String(\"dir\", \"\", \"dir value\")\n+\tdir  = flag.Dir(\"dir\", \"*\", \"\", \"dir value\")\n\tb    = flag.Bool(\"bool\", false, \"bool value\")\n\ts    = flag.String(\"any\", \"\", \"string value\")\n-\topts = flag.String(\"choose\", \"\", \"some items to choose from\")\n+\topts = flag.Choice(\"choose\", []string{\"work\", \"drink\"}, \"\", \"some items to choose from\")\n)\n\nfunc main() {\n+\tflag.SetInstallFlags(\"complete\", \"uncomplete\")\n\tflag.Parse()\n+\tif flag.Complete() {  // runs bash completion if necessary\n+\t\treturn  // return from main without executing the rest of the command\n+\t}\n    ...\n}\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fposener%2Fflag","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fposener%2Fflag","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fposener%2Fflag/lists"}