Skip to content

Regression: Switch to cmds lib 1.0 Changes Behaviour of WithDefault #166

Description

@kevina

It seams that the new command library changes the behavior of WithDefault (previous called just Default before #4403). From what I can tell it changes it in two ways:

(1) Using WithDefault interfere with discovering if that option was specified on the command line. For example I noticed these changes in the core/commands/add.go (in commit 4909c5a56d256e0b999d11b065227b94576609ce):

- cmdkit.IntOption(cidVersionOptionName, "Cid version. Non-zero value will change default of 'raw-leaves' to true. (experimental)").WithDefault(0),
+ cmdkit.IntOption(cidVersionOptionName, "CID version. Defaults to 0 unless an option that depends on CIDv1 is passed. (experimental)"),
- hashFunStr, hfset := req.Options[hashOptionName].(string) 
+ hashFunStr, _ := req.Options[hashOptionName].(string)

(2) I noticed that when WithDefault is used a value is always passed with the API when before I am fairly sure it was not.

I am not 100% sure but it appears that using WIthDefault sets a value client side rather when doing the intended purpose of this function and setting an alternative default server side.

Related: #4911

CC @keks @Stebalien

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions