Skip to content

MarkFlagsRequiredTogether function does not work as expected if any required flag provided #1843

Closed
@bilalcaliskan

Description

Hello folks, I have noticed a strange behavior about MarkFlagsRequiredTogether function. I am using cobra v1.6.1 with Golang 1.19.1. Here is the code snippet:

rootCmd.MarkFlagsRequiredTogether("accessKey", "secretKey", "bucketName", "substring", "region")

If i dont provide any of the flags, i expect cobra to throw an error but somehow it is not throwing an error. It passes that line and fails on normal application flow as expected.

BUT; if i provide at least one required flag, it gives me my desired error like that(assume that i have provided secretKey flag:

Error: if any flags in the group [accessKey secretKey bucketName substring region] are set they must all be set; missing [accessKey bucketName region substring]

Btw i am willing to contribute that project by finding the problematic part of the code and throwing desired error. Cheers!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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