Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
kevina opened this issue Aug 15, 2018 · 1 comment
Open

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

kevina opened this issue Aug 15, 2018 · 1 comment

Comments

@kevina
Copy link
Contributor

kevina commented Aug 15, 2018

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

@Stebalien
Copy link
Member

This is the case and yes, it's not optimal.

@Stebalien Stebalien transferred this issue from ipfs/kubo May 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants