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
|
cidsStr := make([]string, len(cids))
|
||||||
for _, c := range cids {
|
for i, c := range cids {
|
||||||
cidsStr = append(cidsStr, c.String())
|
cidsStr[i] = c.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
err := c.do(
|
err := c.do(
|
||||||
|
|
|
@ -860,8 +860,8 @@ The filter only takes effect when listing all pins. The possible values are:
|
||||||
Description: `
|
Description: `
|
||||||
This command retrieves the status of the CIDs tracked by IPFS
|
This command retrieves the status of the CIDs tracked by IPFS
|
||||||
Cluster, including which member is pinning them and any errors.
|
Cluster, including which member is pinning them and any errors.
|
||||||
If a CID is provided, the status will be only fetched for a single
|
If one of several CIDs are provided, the status will be only fetched
|
||||||
item. Metadata CIDs are included in the status response
|
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
|
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.
|
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:
|
separated list). The following are valid status values:
|
||||||
|
|
||||||
` + trackerStatusAllString(),
|
` + trackerStatusAllString(),
|
||||||
ArgsUsage: "[CID]",
|
ArgsUsage: "[CID1] [CID2]...",
|
||||||
Flags: []cli.Flag{
|
Flags: []cli.Flag{
|
||||||
localFlag(),
|
localFlag(),
|
||||||
cli.StringFlag{
|
cli.StringFlag{
|
||||||
|
@ -880,11 +880,18 @@ separated list). The following are valid status values:
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
Action: func(c *cli.Context) error {
|
Action: func(c *cli.Context) error {
|
||||||
cidStr := c.Args().First()
|
cidsStr := c.Args()
|
||||||
if cidStr != "" {
|
cids := make([]cid.Cid, len(cidsStr))
|
||||||
ci, err := cid.Decode(cidStr)
|
for i, cStr := range cidsStr {
|
||||||
|
ci, err := cid.Decode(cStr)
|
||||||
checkErr("parsing cid", err)
|
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)
|
formatResponse(c, resp, cerr)
|
||||||
} else {
|
} else {
|
||||||
filterFlag := c.String("filter")
|
filterFlag := c.String("filter")
|
||||||
|
|
Loading…
Reference in New Issue
Block a user