Skip to content

go-flags should detect invalid API usage/user error at init time, refuse to work. #159

@dmitshur

Description

@dmitshur

Originally reported in #80 (comment) (/cc @slimsag) but it's inside a closed issue, and didn't seem to get a response.

The issue is that if a user accidentally uses default:"true" on a bool flag, they will have a variable that is unfit to be a flag since it can only ever have the single value true, and there's no way to make it false.

Since it's possible to detect such invalid usage at runtime, it'd be better to treat it as a fatal error rather than letting it go unnoticed.


On another note, while I agree with the rationale mentioned in #80 (comment) that ideally bool values should always start out false and adding them should toggle the value to true, it's also the case that sometimes it might be desirable to temporarily change the default value of a boolean value without having to change the CLI name/logic/API (/cc @renfredxh). I'm not completely sure it's a great idea, but it's worth considering.

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