|
4 | 4 | "bytes"
|
5 | 5 | "fmt"
|
6 | 6 | "strconv"
|
| 7 | + "strings" |
7 | 8 |
|
8 | 9 | "github.com/docker/go-units"
|
9 | 10 | cbor "github.com/ipfs/go-ipld-cbor"
|
@@ -39,7 +40,7 @@ import (
|
39 | 40 | func ActorDealSettlementCmd(getActor ActorAddressGetter) *cli.Command {
|
40 | 41 | return &cli.Command{
|
41 | 42 | Name: "settle-deal",
|
42 |
| - Usage: "Settle deals manually, if dealIds are not provided all deals will be settled", |
| 43 | + Usage: "Settle deals manually, if dealIds are not provided all deals will be settled. Deal IDs can be specified as individual numbers or ranges (e.g., '123 124 125-200 220')", |
43 | 44 | ArgsUsage: "[...dealIds]",
|
44 | 45 | Flags: []cli.Flag{
|
45 | 46 | &cli.IntFlag{
|
@@ -70,12 +71,40 @@ func ActorDealSettlementCmd(getActor ActorAddressGetter) *cli.Command {
|
70 | 71 | // if no deal ids are provided, get all the deals for the miner
|
71 | 72 | if dealsIdArgs := cctx.Args().Slice(); len(dealsIdArgs) != 0 {
|
72 | 73 | for _, d := range dealsIdArgs {
|
73 |
| - dealId, err = strconv.ParseUint(d, 10, 64) |
74 |
| - if err != nil { |
75 |
| - return xerrors.Errorf("Error parsing deal id: %w", err) |
| 74 | + // Check if it's a range (e.g., "125-200") |
| 75 | + if strings.Contains(d, "-") { |
| 76 | + parts := strings.Split(d, "-") |
| 77 | + if len(parts) != 2 { |
| 78 | + return xerrors.Errorf("Invalid range format: %s (expected format: start-end)", d) |
| 79 | + } |
| 80 | + |
| 81 | + start, err := strconv.ParseUint(strings.TrimSpace(parts[0]), 10, 64) |
| 82 | + if err != nil { |
| 83 | + return xerrors.Errorf("Error parsing start of range %s: %w", d, err) |
| 84 | + } |
| 85 | + |
| 86 | + end, err := strconv.ParseUint(strings.TrimSpace(parts[1]), 10, 64) |
| 87 | + if err != nil { |
| 88 | + return xerrors.Errorf("Error parsing end of range %s: %w", d, err) |
| 89 | + } |
| 90 | + |
| 91 | + if start > end { |
| 92 | + return xerrors.Errorf("Invalid range %s: start must be less than or equal to end", d) |
| 93 | + } |
| 94 | + |
| 95 | + // Add all deal IDs in the range (inclusive) |
| 96 | + for id := start; id <= end; id++ { |
| 97 | + dealIDs = append(dealIDs, id) |
| 98 | + } |
| 99 | + } else { |
| 100 | + // Parse as a single deal ID |
| 101 | + dealId, err = strconv.ParseUint(d, 10, 64) |
| 102 | + if err != nil { |
| 103 | + return xerrors.Errorf("Error parsing deal id: %w", err) |
| 104 | + } |
| 105 | + |
| 106 | + dealIDs = append(dealIDs, dealId) |
76 | 107 | }
|
77 |
| - |
78 |
| - dealIDs = append(dealIDs, dealId) |
79 | 108 | }
|
80 | 109 | } else {
|
81 | 110 | if dealIDs, err = GetMinerAllDeals(ctx, api, maddr, types.EmptyTSK); err != nil {
|
|
0 commit comments