From 8646c2fbd5f6b23b971dee43749aea170ce6ae59 Mon Sep 17 00:00:00 2001 From: "Masih H. Derkani" Date: Fri, 1 Nov 2024 11:25:15 +0000 Subject: [PATCH] Conditionally change the limit of F3 certs listed via CLI (#12669) * 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 https://github.com/filecoin-project/lotus/pull/12627#discussion_r1815426539 (cherry picked from commit 773efaeaaa0c12abb9d6e12b93142f7aa22e88b0) --- cli/f3.go | 11 ++++++++--- documentation/en/cli-lotus.md | 12 +++++++----- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/cli/f3.go b/cli/f3.go index 4e7b376c80..7ffd8bae41 100644 --- a/cli/f3.go +++ b/cli/f3.go @@ -135,8 +135,9 @@ An omitted value is always interpreted as 0, and an omitted value indicates the latest instance. If both are specified, must never exceed . -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: @@ -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) @@ -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{ diff --git a/documentation/en/cli-lotus.md b/documentation/en/cli-lotus.md index 7ae791c10d..14dea2e201 100644 --- a/documentation/en/cli-lotus.md +++ b/documentation/en/cli-lotus.md @@ -2773,8 +2773,9 @@ COMMANDS: value indicates the latest instance. If both are specified, must never exceed . - 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: @@ -2830,8 +2831,9 @@ NAME: value indicates the latest instance. If both are specified, must never exceed . - 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: @@ -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 ```