From 242b028656868d11841de72c6ec06991100bd0a5 Mon Sep 17 00:00:00 2001 From: Yasuhiro Matsumoto Date: Tue, 12 Dec 2023 21:34:50 +0900 Subject: [PATCH] -until now --- req.go | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/req.go b/req.go index 12c7e0e..8819f84 100644 --- a/req.go +++ b/req.go @@ -68,7 +68,7 @@ example: Usage: "only accept events newer than this (unix timestamp)", Category: CATEGORY_FILTER_ATTRIBUTES, }, - &cli.IntFlag{ + &cli.StringFlag{ Name: "until", Aliases: []string{"u"}, Usage: "only accept events older than this (unix timestamp)", @@ -196,9 +196,16 @@ example: return fmt.Errorf("parse error: Invalid numeric literal %q", since) } } - if until := c.Int("until"); until != 0 { - ts := nostr.Timestamp(until) - filter.Until = &ts + if until := c.String("until"); until != "" { + if until == "now" { + ts := nostr.Now() + filter.Until = &ts + } else if i, err := strconv.Atoi(until); err == nil { + ts := nostr.Timestamp(i) + filter.Until = &ts + } else { + return fmt.Errorf("parse error: Invalid numeric literal %q", until) + } } if limit := c.Int("limit"); limit != 0 { filter.Limit = limit