fix(decode): handle event id flag

This commit is contained in:
redraw
2024-12-02 10:00:52 -03:00
committed by fiatjaf_
parent 11ae7bc4d3
commit 932361fe8f
2 changed files with 18 additions and 2 deletions

View File

@@ -56,11 +56,15 @@ var decode = &cli.Command{
}
} else if evp := sdk.InputToEventPointer(input); evp != nil {
decodeResult = DecodeResult{EventPointer: evp}
if c.Bool("id") {
stdout(evp.ID)
continue
}
} else if pp := sdk.InputToProfile(ctx, input); pp != nil {
decodeResult = DecodeResult{ProfilePointer: pp}
if c.Bool("pubkey") {
stdout(pp.PublicKey)
return nil
continue
}
} else if prefix, value, err := nip19.Decode(input); err == nil && prefix == "naddr" {
if ep, ok := value.(nostr.EntityPointer); ok {
@@ -76,6 +80,10 @@ var decode = &cli.Command{
continue
}
if c.Bool("pubkey") || c.Bool("id") {
return nil
}
stdout(decodeResult.JSON())
}