mirror of
https://github.com/ipfs/kubo.git
synced 2026-02-21 18:37:45 +08:00
feat: ipfs pin remote ls commands are comma delimited on the CLI only
This commit is contained in:
parent
7588a6a52a
commit
a95a86ed54
@ -224,8 +224,8 @@ Returns a list of objects that are pinned to a remote pinning service.
|
||||
Arguments: []cmds.Argument{},
|
||||
Options: []cmds.Option{
|
||||
cmds.StringOption(pinNameOptionName, "Return pins objects with names that contain provided value (case-sensitive, exact match)."),
|
||||
cmds.StringsOption(pinCIDsOptionName, "Return only pin objects for the specified CID(s); optional, comma separated."),
|
||||
cmds.StringsOption(pinStatusOptionName, "Return only pin objects with the specified statuses (queued,pinning,pinned,failed)").WithDefault([]string{"pinned"}),
|
||||
cmds.DelimitedStringsOption(",", pinCIDsOptionName, "Return only pin objects for the specified CID(s); optional, comma separated."),
|
||||
cmds.DelimitedStringsOption(",", pinStatusOptionName, "Return only pin objects with the specified statuses (queued,pinning,pinned,failed)").WithDefault([]string{"pinned"}),
|
||||
pinServiceNameOption,
|
||||
},
|
||||
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
|
||||
|
||||
if cidsRaw, cidsFound := req.Options[pinCIDsOptionName]; cidsFound {
|
||||
cidsRawArr := cidsRaw.([]string)
|
||||
parsedCIDs := []cid.Cid{}
|
||||
for _, rawCID := range flattenCommaList(cidsRawArr) {
|
||||
var parsedCIDs []cid.Cid
|
||||
for _, rawCID := range cidsRawArr {
|
||||
parsedCID, err := cid.Decode(rawCID)
|
||||
if err != nil {
|
||||
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
|
||||
}
|
||||
if statusRaw, statusFound := req.Options[pinStatusOptionName]; statusFound {
|
||||
statusRawArr := statusRaw.([]string)
|
||||
parsedStatuses := []pinclient.Status{}
|
||||
for _, rawStatus := range flattenCommaList(statusRawArr) {
|
||||
var parsedStatuses []pinclient.Status
|
||||
for _, rawStatus := range statusRawArr {
|
||||
s := pinclient.Status(rawStatus)
|
||||
if s.String() == string(pinclient.StatusUnknown) {
|
||||
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
|
||||
return psCh, errCh, nil
|
||||
}
|
||||
|
||||
func flattenCommaList(list []string) []string {
|
||||
flatList := list[:0]
|
||||
for _, s := range list {
|
||||
flatList = append(flatList, strings.Split(s, ",")...)
|
||||
}
|
||||
return flatList
|
||||
}
|
||||
|
||||
var rmRemotePinCmd = &cmds.Command{
|
||||
Helptext: cmds.HelpText{
|
||||
Tagline: "Remove pinned objects from remote pinning service.",
|
||||
@ -319,8 +311,8 @@ collected if needed.
|
||||
Options: []cmds.Option{
|
||||
pinServiceNameOption,
|
||||
cmds.StringOption(pinNameOptionName, "Remove pin objects with names that contain provided value (case-sensitive, exact match)."),
|
||||
cmds.StringsOption(pinCIDsOptionName, "Remove only pin objects for the specified CID(s)."),
|
||||
cmds.StringsOption(pinStatusOptionName, "Remove only pin objects with the specified statuses (queued,pinning,pinned,failed).").WithDefault([]string{"pinned"}),
|
||||
cmds.DelimitedStringsOption(",", pinCIDsOptionName, "Remove only pin objects for the specified CID(s)."),
|
||||
cmds.DelimitedStringsOption(",", pinStatusOptionName, "Remove only pin objects with the specified statuses (queued,pinning,pinned,failed).").WithDefault([]string{"pinned"}),
|
||||
cmds.BoolOption(pinForceOptionName, "Remove multiple pins without confirmation.").WithDefault(false),
|
||||
},
|
||||
Run: func(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) error {
|
||||
|
||||
3
go.mod
3
go.mod
@ -31,7 +31,7 @@ require (
|
||||
github.com/ipfs/go-graphsync v0.5.1
|
||||
github.com/ipfs/go-ipfs-blockstore v0.1.4
|
||||
github.com/ipfs/go-ipfs-chunker v0.0.5
|
||||
github.com/ipfs/go-ipfs-cmds v0.5.0
|
||||
github.com/ipfs/go-ipfs-cmds v0.6.0
|
||||
github.com/ipfs/go-ipfs-config v0.11.0
|
||||
github.com/ipfs/go-ipfs-ds-help v0.1.1
|
||||
github.com/ipfs/go-ipfs-exchange-interface v0.0.1
|
||||
@ -57,7 +57,6 @@ require (
|
||||
github.com/ipfs/go-verifcid v0.0.1
|
||||
github.com/ipfs/interface-go-ipfs-core v0.4.0
|
||||
github.com/ipld/go-car v0.1.1-0.20201015032735-ff6ccdc46acc
|
||||
github.com/jbenet/go-fuse-version v0.0.0-20160322195114-6d4c97bcf253 // indirect
|
||||
github.com/jbenet/go-is-domain v1.0.5
|
||||
github.com/jbenet/go-random v0.0.0-20190219211222-123a90aedc0c
|
||||
github.com/jbenet/go-temp-err-catcher v0.1.0
|
||||
|
||||
6
go.sum
6
go.sum
@ -327,8 +327,8 @@ github.com/ipfs/go-ipfs-blocksutil v0.0.1/go.mod h1:Yq4M86uIOmxmGPUHv/uI7uKqZNtL
|
||||
github.com/ipfs/go-ipfs-chunker v0.0.1/go.mod h1:tWewYK0we3+rMbOh7pPFGDyypCtvGcBFymgY4rSDLAw=
|
||||
github.com/ipfs/go-ipfs-chunker v0.0.5 h1:ojCf7HV/m+uS2vhUGWcogIIxiO5ubl5O57Q7NapWLY8=
|
||||
github.com/ipfs/go-ipfs-chunker v0.0.5/go.mod h1:jhgdF8vxRHycr00k13FM8Y0E+6BoalYeobXmUyTreP8=
|
||||
github.com/ipfs/go-ipfs-cmds v0.5.0 h1:T1ZT6Qu3IUCp6FgU2IzVtvGLaexEWo9q13+S5ic+Q5Y=
|
||||
github.com/ipfs/go-ipfs-cmds v0.5.0/go.mod h1:ZgYiWVnCk43ChwoH8hAmI1IRbuVtq3GSTHwtRB/Kqhk=
|
||||
github.com/ipfs/go-ipfs-cmds v0.6.0 h1:yAxdowQZzoFKjcLI08sXVNnqVj3jnABbf9smrPQmBsw=
|
||||
github.com/ipfs/go-ipfs-cmds v0.6.0/go.mod h1:ZgYiWVnCk43ChwoH8hAmI1IRbuVtq3GSTHwtRB/Kqhk=
|
||||
github.com/ipfs/go-ipfs-config v0.11.0 h1:w4t2pz415Gtg6MTUKAq06C7ezC59/Us+k3+n1Tje+wg=
|
||||
github.com/ipfs/go-ipfs-config v0.11.0/go.mod h1:Ei/FLgHGTdPyqCPK0oPCwGTe8VSnsjJjx7HZqUb6Ry0=
|
||||
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+
|
||||
github.com/jbenet/go-cienv v0.0.0-20150120210510-1bb1476777ec/go.mod h1:rGaEvXB4uRSZMmzKNLoXvTu1sfx+1kv/DojUlPrSZGs=
|
||||
github.com/jbenet/go-cienv v0.1.0 h1:Vc/s0QbQtoxX8MwwSLWWh+xNNZvM3Lw7NsTcHrvvhMc=
|
||||
github.com/jbenet/go-cienv v0.1.0/go.mod h1:TqNnHUmJgXau0nCzC7kXWeotg3J9W34CUv5Djy1+FlA=
|
||||
github.com/jbenet/go-fuse-version v0.0.0-20160322195114-6d4c97bcf253 h1:+AUuGGAh/2X3wcomiZvjeTcx5OvGXsfdnIqk3KPM+HE=
|
||||
github.com/jbenet/go-fuse-version v0.0.0-20160322195114-6d4c97bcf253/go.mod h1:gWtF+3u3zVe5/+I44niTEcU/KmVo2oMyLh0WhxpBT28=
|
||||
github.com/jbenet/go-is-domain v1.0.5 h1:r92uiHbMEJo9Fkey5pMBtZAzjPQWic0ieo7Jw1jEuQQ=
|
||||
github.com/jbenet/go-is-domain v1.0.5/go.mod h1:xbRLRb0S7FgzDBTJlguhDVwLYM/5yNtvktxj2Ttfy7Q=
|
||||
github.com/jbenet/go-random v0.0.0-20190219211222-123a90aedc0c h1:uUx61FiAa1GI6ZmVd2wf2vULeQZIKG66eybjNXKYCz4=
|
||||
|
||||
Loading…
Reference in New Issue
Block a user