Skip to content

Make flagz be usable with normal flag and spf13/pflag #12

@mwitkow

Description

@mwitkow

Currently we're tied to spf13/pflag due to two things.

First, we're using Annotations. It would be trivial to remove them and rely on whether the Value implements Type() and check the prefix for dyn_.

Secondly, and less trivially, the interfaces for pflag.Value and flag.Value don't match, as well as the types of Flag.

https://godoc.org/flag#Flag
https://godoc.org/flag#Value

vs

https://godoc.org/github.com/spf13/pflag#Flag
https://godoc.org/github.com/spf13/pflag#Value

For Dyn* flags, we could achieve complete independence from spf13/pflag vs flag if FlagSet.Var accepted a Value that could be abstracted as common.

However, for monitoring and debug endpoints, we need calls to VisitAll. These return an explicit Flag type that differs between the two.

The second problem can be worked around by just recompiling flagz with s/flag "github.com/spf13/flag"/"flag" ;)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions