nak req --paginate

This commit is contained in:
fiatjaf
2024-08-18 23:38:03 -03:00
parent c90e61dbec
commit 9690dc70cb
3 changed files with 97 additions and 1 deletions

18
req.go
View File

@@ -96,6 +96,20 @@ example:
Usage: "keep the subscription open, printing all events as they are returned",
DefaultText: "false, will close on EOSE",
},
&cli.BoolFlag{
Name: "paginate",
Usage: "make multiple REQs to the relay decreasing the value of 'until' until 'limit' or 'since' conditions are met",
DefaultText: "false",
},
&cli.DurationFlag{
Name: "paginate-interval",
Usage: "time between queries when using --paginate",
},
&cli.UintFlag{
Name: "paginate-global-limit",
Usage: "global limit at which --paginate should stop",
DefaultText: "uses the value given by --limit/-l or infinite",
},
&cli.BoolFlag{
Name: "bare",
Usage: "when printing the filter, print just the filter, not enveloped in a [\"REQ\", ...] array",
@@ -247,7 +261,9 @@ example:
if len(relayUrls) > 0 {
fn := pool.SubManyEose
if c.Bool("stream") {
if c.Bool("paginate") {
fn = paginateWithPoolAndParams(pool, c.Duration("paginate-interval"), c.Uint("paginate-global-limit"))
} else if c.Bool("stream") {
fn = pool.SubMany
}