From f0d90b567ce3eb0d2eaa4ed32b308540f26b888a Mon Sep 17 00:00:00 2001 From: Yasuhiro Matsumoto Date: Tue, 12 Dec 2023 21:30:04 +0900 Subject: [PATCH] -since now --- req.go | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/req.go b/req.go index 2374b04..12c7e0e 100644 --- a/req.go +++ b/req.go @@ -4,6 +4,7 @@ import ( "encoding/json" "fmt" "os" + "strconv" "strings" "github.com/mailru/easyjson" @@ -61,7 +62,7 @@ example: Usage: "shortcut for --tag p=", Category: CATEGORY_FILTER_ATTRIBUTES, }, - &cli.IntFlag{ + &cli.StringFlag{ Name: "since", Aliases: []string{"s"}, Usage: "only accept events newer than this (unix timestamp)", @@ -184,9 +185,16 @@ example: filter.Tags[tag[0]] = append(filter.Tags[tag[0]], tag[1]) } - if since := c.Int("since"); since != 0 { - ts := nostr.Timestamp(since) - filter.Since = &ts + if since := c.String("since"); since != "" { + if since == "now" { + ts := nostr.Now() + filter.Since = &ts + } else if i, err := strconv.Atoi(since); err == nil { + ts := nostr.Timestamp(i) + filter.Since = &ts + } else { + return fmt.Errorf("parse error: Invalid numeric literal %q", since) + } } if until := c.Int("until"); until != 0 { ts := nostr.Timestamp(until)