{"id":13410465,"url":"https://github.com/sgreben/flagvar","last_synced_at":"2026-03-03T04:38:05.455Z","repository":{"id":57496775,"uuid":"133992101","full_name":"sgreben/flagvar","owner":"sgreben","description":"A collection of CLI argument types for the Go `flag` package.","archived":false,"fork":false,"pushed_at":"2024-09-26T12:57:43.000Z","size":56,"stargazers_count":45,"open_issues_count":0,"forks_count":4,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-08-11T03:27:02.724Z","etag":null,"topics":["argument-parser","cli","enum","glob","golang","json","time","url"],"latest_commit_sha":null,"homepage":"https://pkg.go.dev/github.com/sgreben/flagvar?tab=doc","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sgreben.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-05-18T18:45:16.000Z","updated_at":"2025-02-11T21:34:03.000Z","dependencies_parsed_at":"2024-01-08T14:30:53.133Z","dependency_job_id":"51713233-089c-4748-b8a0-3c380a1e43f2","html_url":"https://github.com/sgreben/flagvar","commit_stats":null,"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"purl":"pkg:github/sgreben/flagvar","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sgreben%2Fflagvar","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sgreben%2Fflagvar/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sgreben%2Fflagvar/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sgreben%2Fflagvar/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sgreben","download_url":"https://codeload.github.com/sgreben/flagvar/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sgreben%2Fflagvar/sbom","scorecard":{"id":814538,"data":{"date":"2025-08-11","repo":{"name":"github.com/sgreben/flagvar","commit":"d9853b6c1b4d63f8f6d2b11024562bab9934351e"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.4,"checks":[{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Code-Review","score":0,"reason":"Found 1/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/gocover.yml:1","Warn: no topLevel permission defined: .github/workflows/test.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/gocover.yml:19: update your workflow using https://app.stepsecurity.io/secureworkflow/sgreben/flagvar/gocover.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/gocover.yml:22: update your workflow using https://app.stepsecurity.io/secureworkflow/sgreben/flagvar/gocover.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/gocover.yml:35: update your workflow using https://app.stepsecurity.io/secureworkflow/sgreben/flagvar/gocover.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/gocover.yml:42: update your workflow using https://app.stepsecurity.io/secureworkflow/sgreben/flagvar/gocover.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/gocover.yml:52: update your workflow using https://app.stepsecurity.io/secureworkflow/sgreben/flagvar/gocover.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:13: update your workflow using https://app.stepsecurity.io/secureworkflow/sgreben/flagvar/test.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:16: update your workflow using https://app.stepsecurity.io/secureworkflow/sgreben/flagvar/test.yml/master?enable=pin","Info:   0 out of   4 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   3 third-party GitHubAction dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: The Unlicense: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 2 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-23T13:55:43.407Z","repository_id":57496775,"created_at":"2025-08-23T13:55:43.407Z","updated_at":"2025-08-23T13:55:43.407Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30032048,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-03T03:27:35.548Z","status":"ssl_error","status_checked_at":"2026-03-03T03:27:09.213Z","response_time":61,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["argument-parser","cli","enum","glob","golang","json","time","url"],"created_at":"2024-07-30T20:01:07.129Z","updated_at":"2026-03-03T04:38:05.421Z","avatar_url":"https://github.com/sgreben.png","language":"Go","readme":"# flagvar\n\n[![Coverage](https://img.shields.io/badge/Coverage-95.5%25-brightgreen)](https://github.com/sgreben/flagvar/actions/workflows/gocover.yaml)\n\n[![Test](https://github.com/sgreben/flagvar/workflows/Test/badge.svg)](https://github.com/sgreben/flagvar/actions/workflows/test.yml)\n[![Go Reference](https://pkg.go.dev/badge/github.com/sgreben/flagvar.svg)](https://pkg.go.dev/github.com/sgreben/flagvar)\n[![Go Report Card](https://goreportcard.com/badge/github.com/sgreben/flagvar)](https://goreportcard.com/report/github.com/sgreben/flagvar)\n\n\nA collection of CLI argument types for the `flag` package.\n\n```go\nimport \"github.com/sgreben/flagvar\"\n```\n\nOr just copy \u0026 paste what you need. It's public domain.\n\n\u003c!-- TOC --\u003e\n\n- [Example](#example)\n- [Conventions](#conventions)\n- [Types](#types)\n- [Goals / design principles](#goals--design-principles)\n\n\u003c!-- /TOC --\u003e\n\n## Example\n\n```go\npackage main\n\nimport (\n\t\"flag\"\n\t\"fmt\"\n\t\"github.com/sgreben/flagvar\"\n)\n\nvar (\n\tfruit    = flagvar.Enum{Choices: []string{\"apple\", \"banana\"}}\n\turls     flagvar.URLs\n\tsettings flagvar.Assignments\n)\n\nfunc main() {\n\tflag.Var(\u0026fruit, \"fruit\", fmt.Sprintf(\"set a fruit (%s)\", fruit.Help()))\n\tflag.Var(\u0026urls, \"url\", \"add a URL\")\n\tflag.Var(\u0026settings, \"set\", fmt.Sprintf(\"specify a setting (%s)\", settings.Help()))\n\tflag.Parse()\n}\n```\n\n```sh\n$ go run main.go -set abc=xyz -url https://github.com\n# no error\n\n$ go run main.go -set abc=xyz -url ://github.com\ninvalid value \"://github.com\" for flag -url: parse ://github.com: missing protocol scheme\n\n$ go run main.go -fruit kiwi\ninvalid value \"kiwi\" for flag -fruit: \"kiwi\" must be one of [apple banana]\n\n$ go run main.go -h\nUsage:\n  -fruit value\n        set a fruit (one of [apple banana])\n  -set value\n        specify a setting (a key/value pair KEY=VALUE)\n  -url value\n        add a URL\n```\n\n## Conventions\n\n- Pluralized argument types (e.g. `Strings`, `Assignments`) can be specified repeatedly, the values are collected in a slice.\n- The resulting value is stored in `.Value` for singular types and in `.Values` for plural types\n- The original argument string is stored in `.Text` for singular types and in `.Texts` for plural types\n- -Set types (`EnumSet`, `StringSet`) de-duplicate provided values.\n- -CSV types (`IntsCSV`, `EnumsCSV`) accept comma-separated values and accumulate values across flag instances if their `.Accumulate` field is set to `true`.\n- Most types implement `interface{ Help() string }`, which produces a string suitable for inclusion in a help message.\n\n## Types\n\nHere's a compact overview:\n\n| `flagvar` type                                                                | example CLI arg           | type of resulting Go value |\n| ----------------------------------------------------------------------------- | ------------------------- | -------------------------- |\n| [Alternative](https://godoc.org/github.com/sgreben/flagvar#Alternative)       |                           |                            |\n| [Assignment](https://godoc.org/github.com/sgreben/flagvar#Assignment)         | KEY=VALUE                 | struct{Key,Value}          |\n| [Assignments](https://godoc.org/github.com/sgreben/flagvar#Assignments)       | KEY=VALUE                 | []struct{Key,Value}        |\n| [AssignmentsMap](https://godoc.org/github.com/sgreben/flagvar#AssignmentsMap) | KEY=VALUE                 | map[string]string          |\n| [CIDR](https://godoc.org/github.com/sgreben/flagvar#CIDR)                     | 127.0.0.1/24              | struct{IPNet,IP}           |\n| [CIDRs](https://godoc.org/github.com/sgreben/flagvar#CIDRs)                   | 127.0.0.1/24              | []struct{IPNet,IP}         |\n| [CIDRsCSV](https://godoc.org/github.com/sgreben/flagvar#CIDRsCSV)             | 127.0.0.1/16,10.1.2.3/8   | []struct{IPNet,IP}         |\n| [Enum](https://godoc.org/github.com/sgreben/flagvar#Enum)                     | apple                     | string                     |\n| [Enums](https://godoc.org/github.com/sgreben/flagvar#Enums)                   | apple                     | []string                   |\n| [EnumsCSV](https://godoc.org/github.com/sgreben/flagvar#EnumsCSV)             | apple,banana              | []string                   |\n| [EnumSet](https://godoc.org/github.com/sgreben/flagvar#EnumSet)               | apple                     | []string                   |\n| [EnumSetCSV](https://godoc.org/github.com/sgreben/flagvar#EnumSetCSV)         | apple,banana              | []string                   |\n| [File](https://godoc.org/github.com/sgreben/flagvar#File)                     | ./README.md               | string                     |\n| [Files](https://godoc.org/github.com/sgreben/flagvar#Files)                   | ./README.md               | []string                   |\n| [Floats](https://godoc.org/github.com/sgreben/flagvar#Floats)                 | 1.234                     | []float64                  |\n| [FloatsCSV](https://godoc.org/github.com/sgreben/flagvar#FloatsCSV)           | 1.234,5.0                 | []float64                  |\n| [Glob](https://godoc.org/github.com/sgreben/flagvar#Glob)                     | src/**.js                 | glob.Glob                  |\n| [Globs](https://godoc.org/github.com/sgreben/flagvar#Globs)                   | src/**.js                 | []glob.Glob                |\n| [Ints](https://godoc.org/github.com/sgreben/flagvar#Ints)                     | 1002                      | []int64                    |\n| [IntsCSV](https://godoc.org/github.com/sgreben/flagvar#IntsCSV)               | 123,1002                  | []int64                    |\n| [IP](https://godoc.org/github.com/sgreben/flagvar#IP)                         | 127.0.0.1                 | net.IP                     |\n| [IPs](https://godoc.org/github.com/sgreben/flagvar#IPs)                       | 127.0.0.1                 | []net.IP                   |\n| [IPsCSV](https://godoc.org/github.com/sgreben/flagvar#IPsCSV)                 | 127.0.0.1,10.1.2.3        | []net.IP                   |\n| [JSON](https://godoc.org/github.com/sgreben/flagvar#JSON)                     | '{\"a\":1}'                 | interface{}                |\n| [JSONs](https://godoc.org/github.com/sgreben/flagvar#JSONs)                   | '{\"a\":1}'                 | []interface{}              |\n| [Regexp](https://godoc.org/github.com/sgreben/flagvar#Regexp)                 | [a-z]+                    | *regexp.Regexp             |\n| [Regexps](https://godoc.org/github.com/sgreben/flagvar#Regexps)               | [a-z]+                    | []*regexp.Regexp           |\n| [Strings](https://godoc.org/github.com/sgreben/flagvar#Strings)               | \"xyxy\"                    | []string                   |\n| [StringSet](https://godoc.org/github.com/sgreben/flagvar#StringSet)           | \"xyxy\"                    | []string                   |\n| [StringSetCSV](https://godoc.org/github.com/sgreben/flagvar#StringSetCSV)     | y,x,y                     | []string                   |\n| [TCPAddr](https://godoc.org/github.com/sgreben/flagvar#TCPAddr)               | 127.0.0.1:10              | net.TCPAddr                |\n| [TCPAddrs](https://godoc.org/github.com/sgreben/flagvar#TCPAddrs)             | 127.0.0.1:10              | []net.TCPAddr              |\n| [TCPAddrsCSV](https://godoc.org/github.com/sgreben/flagvar#TCPAddrsCSV)       | 127.0.0.1:10,:123         | []net.TCPAddr              |\n| [Template](https://godoc.org/github.com/sgreben/flagvar#Template)             | \"{{.Size}}\"               | *template.Template         |\n| [Templates](https://godoc.org/github.com/sgreben/flagvar#Templates)           | \"{{.Size}}\"               | []*template.Template       |\n| [TemplateFile](https://godoc.org/github.com/sgreben/flagvar#TemplateFile)     | \"/path/to/template.file\"  | string                     |\n| [Time](https://godoc.org/github.com/sgreben/flagvar#Time)                     | \"10:30 AM\"                | time.Time                  |\n| [Times](https://godoc.org/github.com/sgreben/flagvar#Times)                   | \"10:30 AM\"                | []time.Time                |\n| [TimeFormat](https://godoc.org/github.com/sgreben/flagvar#TimeFormat)         | \"RFC3339\"                 | string                     |\n| [UDPAddr](https://godoc.org/github.com/sgreben/flagvar#UDPAddr)               | 127.0.0.1:10              | net.UDPAddr                |\n| [UDPAddrs](https://godoc.org/github.com/sgreben/flagvar#UDPAddrs)             | 127.0.0.1:10              | []net.UDPAddr              |\n| [UDPAddrsCSV](https://godoc.org/github.com/sgreben/flagvar#UDPAddrsCSV)       | 127.0.0.1:10,:123         | []net.UDPAddr              |\n| [UnixAddr](https://godoc.org/github.com/sgreben/flagvar#UnixAddr)             | /example.sock             | net.UnixAddr               |\n| [UnixAddrs](https://godoc.org/github.com/sgreben/flagvar#UnixAddrs)           | /example.sock             | []net.UnixAddr             |\n| [UnixAddrsCSV](https://godoc.org/github.com/sgreben/flagvar#UnixAddrsCSV)     | /example.sock,/other.sock | []net.UnixAddr             |\n| [URL](https://godoc.org/github.com/sgreben/flagvar#URL)                       | https://github.com        | *url.URL                   |\n| [URLs](https://godoc.org/github.com/sgreben/flagvar#URLs)                     | https://github.com        | []*url.URL                 |\n| [Wrap](https://godoc.org/github.com/sgreben/flagvar#Wrap)                     |                           |                            |\n| [WrapCSV](https://godoc.org/github.com/sgreben/flagvar#WrapCSV)               |                           |                            |\n| [WrapFunc](https://godoc.org/github.com/sgreben/flagvar#WrapFunc)             |                           |                            |\n| [WrapPointer](https://godoc.org/github.com/sgreben/flagvar#WrapPointer)       |                           |                            |\n\n## Goals / design principles\n\n- Help avoid dependencies\n    - Self-contained \u003e DRY\n    - Explicitly support copy \u0026 paste workflow\n    - Copyable units should be easy to determine\n    - Anonymous structs \u003e shared types\n- \"Code-you-own\" feeling, even when imported as a package\n    - No private fields / methods\n    - No magic\n    - Simple built-in types used wherever possible\n    - Avoid introducing new concepts\n- Support \"blind\" usage\n    - Zero values should be useful\n    - Avoid introducing failure cases, handle any combination of parameters gracefully.\n    - All \"obvious things to try\" should work.\n","funding_links":[],"categories":["命令行","Command Line","Build Automation","命令行工具### 标准 CLI`用于创建一个标准命令行应用程序的库`","命令行工具"],"sub_categories":["标准CLI","Standard CLI","标准 CLI"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsgreben%2Fflagvar","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsgreben%2Fflagvar","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsgreben%2Fflagvar/lists"}