mirror of
https://github.com/fiatjaf/nak.git
synced 2024-10-30 09:09:08 -04:00
improve count
.
This commit is contained in:
parent
6ccca357e2
commit
c214513304
24
count.go
24
count.go
|
@ -14,12 +14,7 @@ const CATEGORY_COUNT_ATTRIBUTES = "FILTER ATTRIBUTES"
|
||||||
var count = &cli.Command{
|
var count = &cli.Command{
|
||||||
Name: "count",
|
Name: "count",
|
||||||
Usage: "generates encoded COUNT messages and optionally use them to talk to relays",
|
Usage: "generates encoded COUNT messages and optionally use them to talk to relays",
|
||||||
Description: `outputs a NIP-45 request. Mostly same as req.
|
Description: `outputs a NIP-45 request -- (mostly the same as 'nak req').`,
|
||||||
|
|
||||||
example usage (with 'nostcat'):
|
|
||||||
nak count -k 1 -a 3bf0c63fcb93463407af97a5e5ee64fa883d107ef9e558472c4eb9aaaefa459d | nostcat wss://nos.lol
|
|
||||||
standalone:
|
|
||||||
nak count -k 1 wss://nos.lol`,
|
|
||||||
Flags: []cli.Flag{
|
Flags: []cli.Flag{
|
||||||
&cli.StringSliceFlag{
|
&cli.StringSliceFlag{
|
||||||
Name: "author",
|
Name: "author",
|
||||||
|
@ -27,12 +22,6 @@ standalone:
|
||||||
Usage: "only accept events from these authors (pubkey as hex)",
|
Usage: "only accept events from these authors (pubkey as hex)",
|
||||||
Category: CATEGORY_FILTER_ATTRIBUTES,
|
Category: CATEGORY_FILTER_ATTRIBUTES,
|
||||||
},
|
},
|
||||||
&cli.StringSliceFlag{
|
|
||||||
Name: "id",
|
|
||||||
Aliases: []string{"i"},
|
|
||||||
Usage: "only accept events with these ids (hex)",
|
|
||||||
Category: CATEGORY_FILTER_ATTRIBUTES,
|
|
||||||
},
|
|
||||||
&cli.IntSliceFlag{
|
&cli.IntSliceFlag{
|
||||||
Name: "kind",
|
Name: "kind",
|
||||||
Aliases: []string{"k"},
|
Aliases: []string{"k"},
|
||||||
|
@ -77,11 +66,6 @@ standalone:
|
||||||
Name: "bare",
|
Name: "bare",
|
||||||
Usage: "when printing the filter, print just the filter, not enveloped in a [\"COUNT\", ...] array",
|
Usage: "when printing the filter, print just the filter, not enveloped in a [\"COUNT\", ...] array",
|
||||||
},
|
},
|
||||||
&cli.BoolFlag{
|
|
||||||
Name: "stream",
|
|
||||||
Usage: "keep the subscription open, printing all events as they are returned",
|
|
||||||
DefaultText: "false, will close on EOSE",
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
ArgsUsage: "[relay...]",
|
ArgsUsage: "[relay...]",
|
||||||
Action: func(c *cli.Context) error {
|
Action: func(c *cli.Context) error {
|
||||||
|
@ -137,11 +121,7 @@ standalone:
|
||||||
relays := c.Args().Slice()
|
relays := c.Args().Slice()
|
||||||
if len(relays) > 0 {
|
if len(relays) > 0 {
|
||||||
pool := nostr.NewSimplePool(c.Context)
|
pool := nostr.NewSimplePool(c.Context)
|
||||||
fn := pool.SubManyEose
|
for evt := range pool.SubManyEose(c.Context, relays, nostr.Filters{filter}) {
|
||||||
if c.Bool("stream") {
|
|
||||||
fn = pool.SubMany
|
|
||||||
}
|
|
||||||
for evt := range fn(c.Context, relays, nostr.Filters{filter}) {
|
|
||||||
fmt.Println(evt)
|
fmt.Println(evt)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user