Skip to content

Commit

Permalink
Conditionally change the limit of F3 certs listed via CLI (#12669)
Browse files Browse the repository at this point in the history
* When no range is given, default limit to 10
* Otherwise default to unlimited.

This is better than the current default of always unlimited because:
* there are a lot of certs, and
* when range is given the chances are the user wants all of them.

Addresses #12627 (comment)

(cherry picked from commit 773efae)
  • Loading branch information
masih committed Nov 4, 2024
1 parent bf725c7 commit 8646c2f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
11 changes: 8 additions & 3 deletions cli/f3.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,9 @@ An omitted <from> value is always interpreted as 0, and an omitted
<to> value indicates the latest instance. If both are specified, <from>
must never exceed <to>.
If no range is specified all certificates are listed, i.e. the range
of '0..'.
If no range is specified, the latest 10 certificates are listed, i.e.
the range of '0..' with limit of 10. Otherwise, all certificates in
the specified range are listed unless limit is explicitly specified.
Examples:
* All certificates from newest to oldest:
Expand Down Expand Up @@ -181,6 +182,10 @@ Examples:
fromTo := cctx.Args().First()
if fromTo == "" {
fromTo = "0.."
if !cctx.IsSet(f3FlagInstanceLimit.Name) {
// Default to limit of 10 if no explicit range and limit is given.
limit = 10
}
}
r, err := newRanger(fromTo, limit, reverse, func() (uint64, error) {
latest, err := api.F3GetLatestCertificate(cctx.Context)
Expand Down Expand Up @@ -306,7 +311,7 @@ Examples:
f3FlagInstanceLimit = &cli.IntFlag{
Name: "limit",
Usage: "The maximum number of instances. A value less than 0 indicates no limit.",
DefaultText: "No limit",
DefaultText: "10 when no range is specified. Otherwise, unlimited.",
Value: -1,
}
f3FlagReverseOrder = &cli.BoolFlag{
Expand Down
12 changes: 7 additions & 5 deletions documentation/en/cli-lotus.md
Original file line number Diff line number Diff line change
Expand Up @@ -2773,8 +2773,9 @@ COMMANDS:
<to> value indicates the latest instance. If both are specified, <from>
must never exceed <to>.
If no range is specified all certificates are listed, i.e. the range
of '0..'.
If no range is specified, the latest 10 certificates are listed, i.e.
the range of '0..' with limit of 10. Otherwise, all certificates in
the specified range are listed unless limit is explicitly specified.
Examples:
* All certificates from newest to oldest:
Expand Down Expand Up @@ -2830,8 +2831,9 @@ NAME:
<to> value indicates the latest instance. If both are specified, <from>
must never exceed <to>.
If no range is specified all certificates are listed, i.e. the range
of '0..'.
If no range is specified, the latest 10 certificates are listed, i.e.
the range of '0..' with limit of 10. Otherwise, all certificates in
the specified range are listed unless limit is explicitly specified.
Examples:
* All certificates from newest to oldest:
Expand All @@ -2858,7 +2860,7 @@ USAGE:
OPTIONS:
--output value The output format. Supported formats: text, json (default: "text")
--limit value The maximum number of instances. A value less than 0 indicates no limit. (default: No limit)
--limit value The maximum number of instances. A value less than 0 indicates no limit. (default: 10 when no range is specified. Otherwise, unlimited.)
--reverse Reverses the default order of output. (default: false)
--help, -h show help
```
Expand Down

0 comments on commit 8646c2f

Please sign in to comment.