Cobra: Support IsSet() method on flags

Created on 23 May 2017  路  2Comments  路  Source: spf13/cobra

To distinguish when the flag got default value because user didnt set any or user explicitly set the flag to same value as the default value.

Most helpful comment

You can use Changed func to check it:

if cmd.Flags().Changed("someFlag") {
    // user set the flag
}

All 2 comments

You can use Changed func to check it:

if cmd.Flags().Changed("someFlag") {
    // user set the flag
}

Thanks! That worked.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

lukasmalkmus picture lukasmalkmus  路  4Comments

mdaymard picture mdaymard  路  5Comments

andygrunwald picture andygrunwald  路  6Comments

alapidas picture alapidas  路  3Comments

jjzcru picture jjzcru  路  3Comments