ipfs-cluster-ctl: support "status cid1 cid2 ..."
This commit is contained in:
parent
a1b6dabbb0
commit
00b7925e78
|
@ -250,9 +250,9 @@ func (c *defaultClient) statusAllWithCids(ctx context.Context, filter api.Tracke
|
|||
}
|
||||
}
|
||||
|
||||
var cidsStr []string
|
||||
for _, c := range cids {
|
||||
cidsStr = append(cidsStr, c.String())
|
||||
cidsStr := make([]string, len(cids))
|
||||
for i, c := range cids {
|
||||
cidsStr[i] = c.String()
|
||||
}
|
||||
|
||||
err := c.do(
|
||||
|
|
|
@ -860,8 +860,8 @@ The filter only takes effect when listing all pins. The possible values are:
|
|||
Description: `
|
||||
This command retrieves the status of the CIDs tracked by IPFS
|
||||
Cluster, including which member is pinning them and any errors.
|
||||
If a CID is provided, the status will be only fetched for a single
|
||||
item. Metadata CIDs are included in the status response
|
||||
If one of several CIDs are provided, the status will be only fetched
|
||||
for a single item. Metadata CIDs are included in the status response.
|
||||
|
||||
When the --local flag is passed, it will only fetch the status from the
|
||||
contacted cluster peer. By default, status will be fetched from all peers.
|
||||
|
@ -871,7 +871,7 @@ where status of the pin matches at least one of the filter values (a comma
|
|||
separated list). The following are valid status values:
|
||||
|
||||
` + trackerStatusAllString(),
|
||||
ArgsUsage: "[CID]",
|
||||
ArgsUsage: "[CID1] [CID2]...",
|
||||
Flags: []cli.Flag{
|
||||
localFlag(),
|
||||
cli.StringFlag{
|
||||
|
@ -880,11 +880,18 @@ separated list). The following are valid status values:
|
|||
},
|
||||
},
|
||||
Action: func(c *cli.Context) error {
|
||||
cidStr := c.Args().First()
|
||||
if cidStr != "" {
|
||||
ci, err := cid.Decode(cidStr)
|
||||
cidsStr := c.Args()
|
||||
cids := make([]cid.Cid, len(cidsStr))
|
||||
for i, cStr := range cidsStr {
|
||||
ci, err := cid.Decode(cStr)
|
||||
checkErr("parsing cid", err)
|
||||
resp, cerr := globalClient.Status(ctx, ci, c.Bool("local"))
|
||||
cids[i] = ci
|
||||
}
|
||||
if len(cids) == 1 {
|
||||
resp, cerr := globalClient.Status(ctx, cids[0], c.Bool("local"))
|
||||
formatResponse(c, resp, cerr)
|
||||
} else if len(cids) > 1 {
|
||||
resp, cerr := globalClient.StatusCids(ctx, cids, c.Bool("local"))
|
||||
formatResponse(c, resp, cerr)
|
||||
} else {
|
||||
filterFlag := c.String("filter")
|
||||
|
|
Loading…
Reference in New Issue
Block a user