{"id":17287422,"url":"https://github.com/adamslevy/flagbind","last_synced_at":"2025-04-14T11:31:50.709Z","repository":{"id":44147834,"uuid":"244244068","full_name":"AdamSLevy/flagbind","owner":"AdamSLevy","description":"Define rich flags with struct tags to make writing CLIs a breeze","archived":false,"fork":false,"pushed_at":"2024-11-02T18:07:59.000Z","size":81,"stargazers_count":4,"open_issues_count":1,"forks_count":3,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-13T23:37:54.232Z","etag":null,"topics":[],"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/AdamSLevy.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":"2020-03-02T00:04:22.000Z","updated_at":"2024-11-02T18:24:42.000Z","dependencies_parsed_at":"2022-09-26T18:31:03.325Z","dependency_job_id":null,"html_url":"https://github.com/AdamSLevy/flagbind","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/AdamSLevy%2Fflagbind","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AdamSLevy%2Fflagbind/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AdamSLevy%2Fflagbind/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AdamSLevy%2Fflagbind/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AdamSLevy","download_url":"https://codeload.github.com/AdamSLevy/flagbind/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248871877,"owners_count":21175309,"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":[],"created_at":"2024-10-15T10:02:25.227Z","updated_at":"2025-04-14T11:31:50.355Z","avatar_url":"https://github.com/AdamSLevy.png","language":"Go","readme":"# `package flagbind`\n\n[![GoDoc](https://godoc.org/github.com/AdamSLevy/flagbind?status.svg)](https://godoc.org/github.com/AdamSLevy/flagbind)\n[![Build Status](https://travis-ci.org/AdamSLevy/flagbind.svg?branch=master)](https://travis-ci.org/AdamSLevy/flagbind)\n[![Coverage Status](https://coveralls.io/repos/github/AdamSLevy/flagbind/badge.svg?branch=master)](https://coveralls.io/github/AdamSLevy/flagbind?branch=master)\n\nPackage `flagbind` parses the exported fields of a struct and binds them to\nflags in a `flag.FlagSet` or `pflag.FlagSet`.\n\n`Bind` allows for creating flags declaratively right alongside the definition\nof their containing struct. For example, the following stuct could be passed to\n`Bind` to populate a `flag.FlagSet` or `pflag.FlagSet`.\n\n```go\nflags := struct {\n        StringFlag string `flag:\"flag-name;default value;Usage for string-flag\"`\n        Int        int    `flag:\"integer;5\"`\n\n        // Flag names default to `auto-kebab-case`\n        AutoKebabCase int\n\n        // If pflag is used, -s is be used as the shorthand flag name,\n        // otherwise it is ignored for use with the standard flag package.\n        ShortName bool `flag:\"short,s\"`\n\n        // Optionally extende the usage tag with subsequent `use` tags\n        // on _ fields.\n        URL string `flag:\"url,u;http://www.example.com/;Start usage here\"\n        _   struct{} `use:\"continue longer usage string for --url below it\",\n\n        // Nested and Embedded structs can add a flag name prefix, or not.\n        Nested     StructA\n        NestedFlat StructB           `flag:\";;;flatten\"`\n        StructA                      // Flat by default\n        StructB    `flag:\"embedded\"` // Add prefix to nested field flag names.\n\n        // Ignored\n        ExplicitlyIgnored bool `flag:\"-\"`\n        unexported        bool\n}{\n        // Default values may also be set directly to override the tag.\n        StringFlag: \"override default\",\n        _URL: \"Include a longer usage string for --url here\",\n}\n\nfs := pflag.NewFlagSet(\"\", pflag.ContinueOnError)\nflagbind.Bind(fs, \u0026flags)\nfs.Parse([]string{\"--auto-kebab-case\"})\n```\n\n`Bind` works seemlessly with both the standard library `flag` package and the\npopular `[github.com/spf13/pflag](https://github.com/spf13/pflag)` package.\n\nIf `pflag` is used, for types that implement `flag.Value` but not\n`pflag.Value`, `Bind` wraps them in an adapter so that they can still be used\nas a `pflag.Value`. The return value of the additional function `Type() string`\nis the type name of the struct field.\n\nAdditional options may be set for each flag. See `Bind` for the full\ndocumentation details.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadamslevy%2Fflagbind","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fadamslevy%2Fflagbind","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadamslevy%2Fflagbind/lists"}