mirror of
https://github.com/ipfs/kubo.git
synced 2026-02-21 10:27:46 +08:00
fix(cli): unify --name param in ls and add (#10439)
This is a cosmetic fix for bug found during testing 0.29.0-rc2.
pin add --name had shorthand -n
pin ls --name had no shorthand, and --names had -n
This unifies -n making it a shorthand for the same parameter in both
`pin ls` and `pin add`.
(cherry picked from commit a07852a3f0)
This commit is contained in:
parent
c526f29b41
commit
5a7029e8cc
@ -359,10 +359,10 @@ Example:
|
||||
},
|
||||
Options: []cmds.Option{
|
||||
cmds.StringOption(pinTypeOptionName, "t", "The type of pinned keys to list. Can be \"direct\", \"indirect\", \"recursive\", or \"all\".").WithDefault("all"),
|
||||
cmds.BoolOption(pinQuietOptionName, "q", "Write just hashes of objects."),
|
||||
cmds.BoolOption(pinQuietOptionName, "q", "Output only the CIDs of pins."),
|
||||
cmds.StringOption(pinNameOptionName, "n", "Limit returned pins to ones with names that contain the value provided (case-sensitive, partial match). Implies --names=true."),
|
||||
cmds.BoolOption(pinStreamOptionName, "s", "Enable streaming of pins as they are discovered."),
|
||||
cmds.BoolOption(pinNamesOptionName, "n", "Enable displaying pin names (slower)."),
|
||||
cmds.StringOption(pinNameOptionName, "Display pins with names that contain the value provided (case-sensitive, partial match)."),
|
||||
cmds.BoolOption(pinNamesOptionName, "Include pin names in the output (slower, disabled by default)."),
|
||||
},
|
||||
Run: func(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) error {
|
||||
api, err := cmdenv.GetApi(env, req)
|
||||
|
||||
@ -17,7 +17,12 @@
|
||||
|
||||
#### Add search functionality for pin names
|
||||
|
||||
It is now possible to search for pins by name. To do so, use `ipfs pin ls --name "SomeName"`. The search is case-sensitive and will return all pins having a name which contains the exact word provided.
|
||||
It is now possible to search for pins by name via `ipfs pin ls --name "SomeName"`.
|
||||
The search is case-sensitive and will return all pins that contain the specified substring in their name.
|
||||
|
||||
> [!TIP]
|
||||
> The `ipfs pin ls -n` is now a shorthand for `ipfs pin ls --name`, mirroring the behavior of `ipfs pin add`.
|
||||
> See `ipfs pin ls --help` for more information.
|
||||
|
||||
#### Customizing `ipfs add` defaults
|
||||
|
||||
@ -27,7 +32,7 @@ The hash function, CID version, or UnixFS raw leaves and chunker behaviors can b
|
||||
> [!TIP]
|
||||
> As a convenience, two CID [profiles](../config.md#profile) are provided: `legacy-cid-v0` and `test-cid-v1`.
|
||||
> A test profile that defaults to modern CIDv1 can be applied via `ipfs config profile apply test-cid-v1`.
|
||||
> We encourage users to try it and report any issues.
|
||||
> We encourage users to try it and report any issues in [kubo#4143](https://github.com/ipfs/kubo/issues/4143).
|
||||
|
||||
### 📝 Changelog
|
||||
|
||||
|
||||
@ -242,7 +242,7 @@ func TestPins(t *testing.T) {
|
||||
require.NotContains(t, lsOut, outADetailed)
|
||||
})
|
||||
|
||||
t.Run("test listing pins which contains specific name", func(t *testing.T) {
|
||||
t.Run("test listing pins with names that contain specific string", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
node := harness.NewT(t).NewNode().Init()
|
||||
@ -254,27 +254,30 @@ func TestPins(t *testing.T) {
|
||||
outB := cidBStr + " recursive testPin"
|
||||
outC := cidCStr + " recursive randPin"
|
||||
|
||||
_ = node.IPFS("pin", "add", "--name", "testPin", cidAStr)
|
||||
lsOut := pinLs(node, "-t=recursive", "--name=test")
|
||||
require.Contains(t, lsOut, outA)
|
||||
lsOut = pinLs(node, "-t=recursive", "--name=randomLabel")
|
||||
require.NotContains(t, lsOut, outA)
|
||||
// make sure both -n and --name work
|
||||
for _, nameParam := range []string{"--name", "-n"} {
|
||||
_ = node.IPFS("pin", "add", "--name", "testPin", cidAStr)
|
||||
lsOut := pinLs(node, "-t=recursive", nameParam+"=test")
|
||||
require.Contains(t, lsOut, outA)
|
||||
lsOut = pinLs(node, "-t=recursive", nameParam+"=randomLabel")
|
||||
require.NotContains(t, lsOut, outA)
|
||||
|
||||
_ = node.IPFS("pin", "add", "--name", "testPin", cidBStr)
|
||||
lsOut = pinLs(node, "-t=recursive", "--name=test")
|
||||
require.Contains(t, lsOut, outA)
|
||||
require.Contains(t, lsOut, outB)
|
||||
_ = node.IPFS("pin", "add", "--name", "testPin", cidBStr)
|
||||
lsOut = pinLs(node, "-t=recursive", nameParam+"=test")
|
||||
require.Contains(t, lsOut, outA)
|
||||
require.Contains(t, lsOut, outB)
|
||||
|
||||
_ = node.IPFS("pin", "add", "--name", "randPin", cidCStr)
|
||||
lsOut = pinLs(node, "-t=recursive", "--name=rand")
|
||||
require.NotContains(t, lsOut, outA)
|
||||
require.NotContains(t, lsOut, outB)
|
||||
require.Contains(t, lsOut, outC)
|
||||
_ = node.IPFS("pin", "add", "--name", "randPin", cidCStr)
|
||||
lsOut = pinLs(node, "-t=recursive", nameParam+"=rand")
|
||||
require.NotContains(t, lsOut, outA)
|
||||
require.NotContains(t, lsOut, outB)
|
||||
require.Contains(t, lsOut, outC)
|
||||
|
||||
lsOut = pinLs(node, "-t=recursive", "--name=testPin")
|
||||
require.Contains(t, lsOut, outA)
|
||||
require.Contains(t, lsOut, outB)
|
||||
require.NotContains(t, lsOut, outC)
|
||||
lsOut = pinLs(node, "-t=recursive", nameParam+"=testPin")
|
||||
require.Contains(t, lsOut, outA)
|
||||
require.Contains(t, lsOut, outB)
|
||||
require.NotContains(t, lsOut, outC)
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("test overwriting pin with name", func(t *testing.T) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user