Regression: Switch to cmds lib 1.0 Changes Behaviour of WithDefault
- Dominant language
- Go
- Stars
- 52
- Forks
- 45
- PR merge metrics
- No merged PRs in 30d
Description
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):
```diff
- 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)"),
```
```diff
- 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
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with core/commands/add.go and compare the WithDefault changes from commit 4909c5a56d256e0b999d11b065227b94576609ce, then read the related discussion in #4911. Reproduce whether WithDefault affects command-line option detection and values sent through the API; the work is done when both behaviors match the intended server-side default semantics.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100