@cryptotaxi247 / kubo / commits / a95a86ed5

feat: ipfs pin remote ls commands are comma delimited on the CLI only

Adin Schmahmann committed Jan 14, 2021 at 19:13 UTC a95a86ed54d6498f6d47232da1cbd111eebbd659
3 files changed +11 -22
core/commands/pin/remotepin.go
+8 -16
@@ -224,8 +224,8 @@ Returns a list of objects that are pinned to a remote pinning service.
224 Arguments: []cmds.Argument{},
225 Options: []cmds.Option{
226 cmds.StringOption(pinNameOptionName, "Return pins objects with names that contain provided value (case-sensitive, exact match)."),
227 - cmds.StringsOption(pinCIDsOptionName, "Return only pin objects for the specified CID(s); optional, comma separated."),
228 - cmds.StringsOption(pinStatusOptionName, "Return only pin objects with the specified statuses (queued,pinning,pinned,failed)").WithDefault([]string{"pinned"}),
227 + cmds.DelimitedStringsOption(",", pinCIDsOptionName, "Return only pin objects for the specified CID(s); optional, comma separated."),
228 + cmds.DelimitedStringsOption(",", pinStatusOptionName, "Return only pin objects with the specified statuses (queued,pinning,pinned,failed)").WithDefault([]string{"pinned"}),
229 pinServiceNameOption,
230 },
231 Run: func(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) error {
@@ -270,8 +270,8 @@ func lsRemote(ctx context.Context, req *cmds.Request, c *pinclient.Client) (chan
270
271 if cidsRaw, cidsFound := req.Options[pinCIDsOptionName]; cidsFound {
272 cidsRawArr := cidsRaw.([]string)
273 - parsedCIDs := []cid.Cid{}
274 - for _, rawCID := range flattenCommaList(cidsRawArr) {
273 + var parsedCIDs []cid.Cid
274 + for _, rawCID := range cidsRawArr {
275 parsedCID, err := cid.Decode(rawCID)
276 if err != nil {
277 return nil, nil, fmt.Errorf("CID %q cannot be parsed: %v", rawCID, err)
@@ -282,8 +282,8 @@ func lsRemote(ctx context.Context, req *cmds.Request, c *pinclient.Client) (chan
282 }
283 if statusRaw, statusFound := req.Options[pinStatusOptionName]; statusFound {
284 statusRawArr := statusRaw.([]string)
285 - parsedStatuses := []pinclient.Status{}
286 - for _, rawStatus := range flattenCommaList(statusRawArr) {
285 + var parsedStatuses []pinclient.Status
286 + for _, rawStatus := range statusRawArr {
287 s := pinclient.Status(rawStatus)
288 if s.String() == string(pinclient.StatusUnknown) {
289 return nil, nil, fmt.Errorf("status %q is not valid", rawStatus)
@@ -298,14 +298,6 @@ func lsRemote(ctx context.Context, req *cmds.Request, c *pinclient.Client) (chan
298 return psCh, errCh, nil
299 }
300
301 -func flattenCommaList(list []string) []string {
302 - flatList := list[:0]
303 - for _, s := range list {
304 - flatList = append(flatList, strings.Split(s, ",")...)
305 - }
306 - return flatList
307 -}
308 -
301 var rmRemotePinCmd = &cmds.Command{
302 Helptext: cmds.HelpText{
303 Tagline: "Remove pinned objects from remote pinning service.",
@@ -319,8 +311,8 @@ collected if needed.
311 Options: []cmds.Option{
312 pinServiceNameOption,
313 cmds.StringOption(pinNameOptionName, "Remove pin objects with names that contain provided value (case-sensitive, exact match)."),
322 - cmds.StringsOption(pinCIDsOptionName, "Remove only pin objects for the specified CID(s)."),
323 - cmds.StringsOption(pinStatusOptionName, "Remove only pin objects with the specified statuses (queued,pinning,pinned,failed).").WithDefault([]string{"pinned"}),
314 + cmds.DelimitedStringsOption(",", pinCIDsOptionName, "Remove only pin objects for the specified CID(s)."),
315 + cmds.DelimitedStringsOption(",", pinStatusOptionName, "Remove only pin objects with the specified statuses (queued,pinning,pinned,failed).").WithDefault([]string{"pinned"}),
316 cmds.BoolOption(pinForceOptionName, "Remove multiple pins without confirmation.").WithDefault(false),
317 },
318 Run: func(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) error {
go.mod
+1 -2
@@ -31,7 +31,7 @@ require (
31 github.com/ipfs/go-graphsync v0.5.1
32 github.com/ipfs/go-ipfs-blockstore v0.1.4
33 github.com/ipfs/go-ipfs-chunker v0.0.5
34 - github.com/ipfs/go-ipfs-cmds v0.5.0
34 + github.com/ipfs/go-ipfs-cmds v0.6.0
35 github.com/ipfs/go-ipfs-config v0.11.0
36 github.com/ipfs/go-ipfs-ds-help v0.1.1
37 github.com/ipfs/go-ipfs-exchange-interface v0.0.1
@@ -57,7 +57,6 @@ require (
57 github.com/ipfs/go-verifcid v0.0.1
58 github.com/ipfs/interface-go-ipfs-core v0.4.0
59 github.com/ipld/go-car v0.1.1-0.20201015032735-ff6ccdc46acc
60 - github.com/jbenet/go-fuse-version v0.0.0-20160322195114-6d4c97bcf253 // indirect
60 github.com/jbenet/go-is-domain v1.0.5
61 github.com/jbenet/go-random v0.0.0-20190219211222-123a90aedc0c
62 github.com/jbenet/go-temp-err-catcher v0.1.0
go.sum
+2 -4
@@ -327,8 +327,8 @@ github.com/ipfs/go-ipfs-blocksutil v0.0.1/go.mod h1:Yq4M86uIOmxmGPUHv/uI7uKqZNtL
327 github.com/ipfs/go-ipfs-chunker v0.0.1/go.mod h1:tWewYK0we3+rMbOh7pPFGDyypCtvGcBFymgY4rSDLAw=
328 github.com/ipfs/go-ipfs-chunker v0.0.5 h1:ojCf7HV/m+uS2vhUGWcogIIxiO5ubl5O57Q7NapWLY8=
329 github.com/ipfs/go-ipfs-chunker v0.0.5/go.mod h1:jhgdF8vxRHycr00k13FM8Y0E+6BoalYeobXmUyTreP8=
330 -github.com/ipfs/go-ipfs-cmds v0.5.0 h1:T1ZT6Qu3IUCp6FgU2IzVtvGLaexEWo9q13+S5ic+Q5Y=
331 -github.com/ipfs/go-ipfs-cmds v0.5.0/go.mod h1:ZgYiWVnCk43ChwoH8hAmI1IRbuVtq3GSTHwtRB/Kqhk=
330 +github.com/ipfs/go-ipfs-cmds v0.6.0 h1:yAxdowQZzoFKjcLI08sXVNnqVj3jnABbf9smrPQmBsw=
331 +github.com/ipfs/go-ipfs-cmds v0.6.0/go.mod h1:ZgYiWVnCk43ChwoH8hAmI1IRbuVtq3GSTHwtRB/Kqhk=
332 github.com/ipfs/go-ipfs-config v0.11.0 h1:w4t2pz415Gtg6MTUKAq06C7ezC59/Us+k3+n1Tje+wg=
333 github.com/ipfs/go-ipfs-config v0.11.0/go.mod h1:Ei/FLgHGTdPyqCPK0oPCwGTe8VSnsjJjx7HZqUb6Ry0=
334 github.com/ipfs/go-ipfs-delay v0.0.0-20181109222059-70721b86a9a8/go.mod h1:8SP1YXK1M1kXuc4KJZINY3TQQ03J2rwBG9QfXmbRPrw=
@@ -429,8 +429,6 @@ github.com/jackpal/go-nat-pmp v1.0.2/go.mod h1:QPH045xvCAeXUZOxsnwmrtiCoxIr9eob+
429 github.com/jbenet/go-cienv v0.0.0-20150120210510-1bb1476777ec/go.mod h1:rGaEvXB4uRSZMmzKNLoXvTu1sfx+1kv/DojUlPrSZGs=
430 github.com/jbenet/go-cienv v0.1.0 h1:Vc/s0QbQtoxX8MwwSLWWh+xNNZvM3Lw7NsTcHrvvhMc=
431 github.com/jbenet/go-cienv v0.1.0/go.mod h1:TqNnHUmJgXau0nCzC7kXWeotg3J9W34CUv5Djy1+FlA=
432 -github.com/jbenet/go-fuse-version v0.0.0-20160322195114-6d4c97bcf253 h1:+AUuGGAh/2X3wcomiZvjeTcx5OvGXsfdnIqk3KPM+HE=
433 -github.com/jbenet/go-fuse-version v0.0.0-20160322195114-6d4c97bcf253/go.mod h1:gWtF+3u3zVe5/+I44niTEcU/KmVo2oMyLh0WhxpBT28=
432 github.com/jbenet/go-is-domain v1.0.5 h1:r92uiHbMEJo9Fkey5pMBtZAzjPQWic0ieo7Jw1jEuQQ=
433 github.com/jbenet/go-is-domain v1.0.5/go.mod h1:xbRLRb0S7FgzDBTJlguhDVwLYM/5yNtvktxj2Ttfy7Q=
434 github.com/jbenet/go-random v0.0.0-20190219211222-123a90aedc0c h1:uUx61FiAa1GI6ZmVd2wf2vULeQZIKG66eybjNXKYCz4=