An open API service providing package, version and dependency metadata of many open source software ecosystems and registries.

Top 8.2% on proxy.golang.org

proxy.golang.org : github.com/alex-held/cobra-flags

Package flagbind makes defining flags as simple as defining a struct type. flagbind.Bind parses the exported fields of a struct and binds them to a FlagSet, which can be the standard flag package or the popular pflag package github.com/spf13/pflag. By coupling the flag definitions with a type definition, the use of globals is discouraged, and flag types may be coupled with related behavior allowing for better organized and documented code. Flag names, usage, defaults and other options can be set using struct tags on exported fields. Using struct nesting, flags can be composed and assigned a flag name prefix. Exposing the settings of another package as flags is as simple as embedding the relevant types. Alternatively, any type may implement the Binder interface, which allows for more direct control over the FlagSet, much like json.Unmarshal passes control to types that implement json.Unmarshaler. Also similar to json.Unmarshal, Bind will initialize any fields that are nil, and leave any fields that are already populated, as defaults. See Bind documentation for the full details on controling flags. Bind works seamlessly with both the standard library flag package and the popular github.com/spf13/pflag package. If pflag is used, Bind adapts a flag.Value to a pflag.Value. The underlying type name of the flag.Value is used as the return value of the additional `Type() string` function required by the pflag.Value interface. Start by declaring a struct type for your flags.

Registry - Source - Documentation - JSON
purl: pkg:golang/github.com/alex-held/cobra-flags
License: MIT
Latest release: over 3 years ago
First release: over 3 years ago
Namespace: github.com/alex-held
Stars: 0 on GitHub
Forks: 0 on GitHub
See more repository details: repos.ecosyste.ms
Last synced: 3 months ago

    Loading...
    Readme
    Loading...