Skip to content

Commit

Permalink
set .DisableSliceFlagSeparator to true.
Browse files Browse the repository at this point in the history
fixes nostr:nevent1qqs9qwgwnr2rzguzrgt99hhhyv8e84mcdr4mnk86uvm6ndjvzl4rjxqpzpmhxue69uhkztnwdaejumr0dshsz9mhwden5te0vf5hgcm0d9hx2u3wwdhkx6tpdshszxnhwden5te0vfhhxarj9ekx2cm5w4exjene9ehx2ap0j8u0fj
  • Loading branch information
fiatjaf committed Aug 7, 2024
1 parent d226cd6 commit c90e61d
Show file tree
Hide file tree
Showing 12 changed files with 61 additions and 39 deletions.
9 changes: 5 additions & 4 deletions bunker.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@ import (
)

var bunker = &cli.Command{
Name: "bunker",
Usage: "starts a NIP-46 signer daemon with the given --sec key",
ArgsUsage: "[relay...]",
Description: ``,
Name: "bunker",
Usage: "starts a NIP-46 signer daemon with the given --sec key",
ArgsUsage: "[relay...]",
Description: ``,
DisableSliceFlagSeparator: true,
Flags: []cli.Flag{
&cli.StringFlag{
Name: "sec",
Expand Down
7 changes: 4 additions & 3 deletions count.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ import (
)

var count = &cli.Command{
Name: "count",
Usage: "generates encoded COUNT messages and optionally use them to talk to relays",
Description: `outputs a NIP-45 request (the flags are mostly the same as 'nak req').`,
Name: "count",
Usage: "generates encoded COUNT messages and optionally use them to talk to relays",
Description: `outputs a NIP-45 request (the flags are mostly the same as 'nak req').`,
DisableSliceFlagSeparator: true,
Flags: []cli.Flag{
&cli.StringSliceFlag{
Name: "author",
Expand Down
1 change: 1 addition & 0 deletions decode.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ var decode = &cli.Command{
nak decode nevent1qqs29yet5tp0qq5xu5qgkeehkzqh5qu46739axzezcxpj4tjlkx9j7gpr4mhxue69uhkummnw3ez6ur4vgh8wetvd3hhyer9wghxuet5sh59ud
nak decode nprofile1qqsrhuxx8l9ex335q7he0f09aej04zpazpl0ne2cgukyawd24mayt8gpz4mhxue69uhk2er9dchxummnw3ezumrpdejqz8thwden5te0dehhxarj94c82c3wwajkcmr0wfjx2u3wdejhgqgcwaehxw309aex2mrp0yhxummnw3exzarf9e3k7mgnp0sh5
nak decode nsec1jrmyhtjhgd9yqalps8hf9mayvd58852gtz66m7tqpacjedkp6kxq4dyxsr`,
DisableSliceFlagSeparator: true,
Flags: []cli.Flag{
&cli.BoolFlag{
Name: "id",
Expand Down
19 changes: 13 additions & 6 deletions encode.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,12 @@ var encode = &cli.Command{
}
return nil
},
DisableSliceFlagSeparator: true,
Commands: []*cli.Command{
{
Name: "npub",
Usage: "encode a hex public key into bech32 'npub' format",
Name: "npub",
Usage: "encode a hex public key into bech32 'npub' format",
DisableSliceFlagSeparator: true,
Action: func(ctx context.Context, c *cli.Command) error {
for target := range getStdinLinesOrArguments(c.Args()) {
if ok := nostr.IsValidPublicKey(target); !ok {
Expand All @@ -48,8 +50,9 @@ var encode = &cli.Command{
},
},
{
Name: "nsec",
Usage: "encode a hex private key into bech32 'nsec' format",
Name: "nsec",
Usage: "encode a hex private key into bech32 'nsec' format",
DisableSliceFlagSeparator: true,
Action: func(ctx context.Context, c *cli.Command) error {
for target := range getStdinLinesOrArguments(c.Args()) {
if ok := nostr.IsValid32ByteHex(target); !ok {
Expand Down Expand Up @@ -78,6 +81,7 @@ var encode = &cli.Command{
Usage: "attach relay hints to nprofile code",
},
},
DisableSliceFlagSeparator: true,
Action: func(ctx context.Context, c *cli.Command) error {
for target := range getStdinLinesOrArguments(c.Args()) {
if ok := nostr.IsValid32ByteHex(target); !ok {
Expand Down Expand Up @@ -116,6 +120,7 @@ var encode = &cli.Command{
Usage: "attach an author pubkey as a hint to the nevent code",
},
},
DisableSliceFlagSeparator: true,
Action: func(ctx context.Context, c *cli.Command) error {
for target := range getStdinLinesOrArguments(c.Args()) {
if ok := nostr.IsValid32ByteHex(target); !ok {
Expand Down Expand Up @@ -174,6 +179,7 @@ var encode = &cli.Command{
Usage: "attach relay hints to naddr code",
},
},
DisableSliceFlagSeparator: true,
Action: func(ctx context.Context, c *cli.Command) error {
for d := range getStdinLinesOrBlank() {
pubkey := c.String("pubkey")
Expand Down Expand Up @@ -211,8 +217,9 @@ var encode = &cli.Command{
},
},
{
Name: "note",
Usage: "generate note1 event codes (not recommended)",
Name: "note",
Usage: "generate note1 event codes (not recommended)",
DisableSliceFlagSeparator: true,
Action: func(ctx context.Context, c *cli.Command) error {
for target := range getStdinLinesOrArguments(c.Args()) {
if ok := nostr.IsValid32ByteHex(target); !ok {
Expand Down
1 change: 1 addition & 0 deletions event.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ if an event -- or a partial event -- is given on stdin, the flags can be used to
example:
echo '{"id":"a889df6a387419ff204305f4c2d296ee328c3cd4f8b62f205648a541b4554dfb","pubkey":"c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee5","created_at":1698623783,"kind":1,"tags":[],"content":"hello from the nostr army knife","sig":"84876e1ee3e726da84e5d195eb79358b2b3eaa4d9bd38456fde3e8a2af3f1cd4cda23f23fda454869975b3688797d4c66e12f4c51c1b43c6d2997c5e61865661"}' | nak event wss://offchain.pub
echo '{"tags": [["t", "spam"]]}' | nak event -c 'this is spam'`,
DisableSliceFlagSeparator: true,
Flags: []cli.Flag{
&cli.StringFlag{
Name: "sec",
Expand Down
1 change: 1 addition & 0 deletions fetch.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ var fetch = &cli.Command{
Description: `example usage:
nak fetch nevent1qqsxrwm0hd3s3fddh4jc2574z3xzufq6qwuyz2rvv3n087zvym3dpaqprpmhxue69uhhqatzd35kxtnjv4kxz7tfdenju6t0xpnej4
echo npub1h8spmtw9m2huyv6v2j2qd5zv956z2zdugl6mgx02f2upffwpm3nqv0j4ps | nak fetch --relay wss://relay.nostr.band`,
DisableSliceFlagSeparator: true,
Flags: []cli.Flag{
&cli.StringSliceFlag{
Name: "relay",
Expand Down
44 changes: 25 additions & 19 deletions key.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@ import (
)

var key = &cli.Command{
Name: "key",
Usage: "operations on secret keys: generate, derive, encrypt, decrypt.",
Description: ``,
Name: "key",
Usage: "operations on secret keys: generate, derive, encrypt, decrypt.",
Description: ``,
DisableSliceFlagSeparator: true,
Commands: []*cli.Command{
generate,
public,
Expand All @@ -31,9 +32,10 @@ var key = &cli.Command{
}

var generate = &cli.Command{
Name: "generate",
Usage: "generates a secret key",
Description: ``,
Name: "generate",
Usage: "generates a secret key",
Description: ``,
DisableSliceFlagSeparator: true,
Action: func(ctx context.Context, c *cli.Command) error {
sec := nostr.GeneratePrivateKey()
stdout(sec)
Expand All @@ -42,10 +44,11 @@ var generate = &cli.Command{
}

var public = &cli.Command{
Name: "public",
Usage: "computes a public key from a secret key",
Description: ``,
ArgsUsage: "[secret]",
Name: "public",
Usage: "computes a public key from a secret key",
Description: ``,
ArgsUsage: "[secret]",
DisableSliceFlagSeparator: true,
Action: func(ctx context.Context, c *cli.Command) error {
for sec := range getSecretKeysFromStdinLinesOrSlice(ctx, c, c.Args().Slice()) {
pubkey, err := nostr.GetPublicKey(sec)
Expand All @@ -60,10 +63,11 @@ var public = &cli.Command{
}

var encrypt = &cli.Command{
Name: "encrypt",
Usage: "encrypts a secret key and prints an ncryptsec code",
Description: `uses the NIP-49 standard.`,
ArgsUsage: "<secret> <password>",
Name: "encrypt",
Usage: "encrypts a secret key and prints an ncryptsec code",
Description: `uses the NIP-49 standard.`,
ArgsUsage: "<secret> <password>",
DisableSliceFlagSeparator: true,
Flags: []cli.Flag{
&cli.IntFlag{
Name: "logn",
Expand Down Expand Up @@ -98,10 +102,11 @@ var encrypt = &cli.Command{
}

var decrypt = &cli.Command{
Name: "decrypt",
Usage: "takes an ncrypsec and a password and decrypts it into an nsec",
Description: `uses the NIP-49 standard.`,
ArgsUsage: "<ncryptsec-code> <password>",
Name: "decrypt",
Usage: "takes an ncrypsec and a password and decrypts it into an nsec",
Description: `uses the NIP-49 standard.`,
ArgsUsage: "<ncryptsec-code> <password>",
DisableSliceFlagSeparator: true,
Action: func(ctx context.Context, c *cli.Command) error {
var ncryptsec string
var password string
Expand Down Expand Up @@ -151,7 +156,8 @@ var combine = &cli.Command{
Description: `The public keys must have 33 bytes (66 characters hex), with the 02 or 03 prefix. It is common in Nostr to drop that first byte, so you'll have to derive the public keys again from the private keys in order to get it back.
However, if the intent is to check if two existing Nostr pubkeys match a given combined pubkey, then it might be sufficient to calculate the combined key for all the possible combinations of pubkeys in the input.`,
ArgsUsage: "[pubkey...]",
ArgsUsage: "[pubkey...]",
DisableSliceFlagSeparator: true,
Action: func(ctx context.Context, c *cli.Command) error {
type Combination struct {
Variants []string `json:"input_variants"`
Expand Down
11 changes: 6 additions & 5 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ import (
)

var app = &cli.Command{
Name: "nak",
Suggest: true,
UseShortOptionHandling: true,
AllowFlagsAfterArguments: true,
Usage: "the nostr army knife command-line tool",
Name: "nak",
Suggest: true,
UseShortOptionHandling: true,
AllowFlagsAfterArguments: true,
Usage: "the nostr army knife command-line tool",
DisableSliceFlagSeparator: true,
Commands: []*cli.Command{
req,
count,
Expand Down
2 changes: 1 addition & 1 deletion musig2.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
)

func performMusig(
ctx context.Context,
_ context.Context,
sec string,
evt *nostr.Event,
numSigners int,
Expand Down
3 changes: 2 additions & 1 deletion relay.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ var relay = &cli.Command{
Usage: "gets the relay information document for the given relay, as JSON",
Description: `example:
nak relay nostr.wine`,
ArgsUsage: "<relay-url>",
ArgsUsage: "<relay-url>",
DisableSliceFlagSeparator: true,
Action: func(ctx context.Context, c *cli.Command) error {
for url := range getStdinLinesOrArguments(c.Args()) {
if url == "" {
Expand Down
1 change: 1 addition & 0 deletions req.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ it can also take a filter from stdin, optionally modify it with flags and send i
example:
echo '{"kinds": [1], "#t": ["test"]}' | nak req -l 5 -k 4549 --tag t=spam wss://nostr-pub.wellorder.net`,
DisableSliceFlagSeparator: true,
Flags: []cli.Flag{
&cli.StringSliceFlag{
Name: "author",
Expand Down
1 change: 1 addition & 0 deletions verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ var verify = &cli.Command{
echo '{"id":"a889df6a387419ff204305f4c2d296ee328c3cd4f8b62f205648a541b4554dfb","pubkey":"c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee5","created_at":1698623783,"kind":1,"tags":[],"content":"hello from the nostr army knife","sig":"84876e1ee3e726da84e5d195eb79358b2b3eaa4d9bd38456fde3e8a2af3f1cd4cda23f23fda454869975b3688797d4c66e12f4c51c1b43c6d2997c5e61865661"}' | nak verify
it outputs nothing if the verification is successful.`,
DisableSliceFlagSeparator: true,
Action: func(ctx context.Context, c *cli.Command) error {
for stdinEvent := range getStdinLinesOrArguments(c.Args()) {
evt := nostr.Event{}
Expand Down

0 comments on commit c90e61d

Please sign in to comment.