mirror of
https://github.com/fiatjaf/nak.git
synced 2025-07-29 08:18:28 -04:00
small fixes on dvm flags and stuff.
This commit is contained in:
3
curl.go
3
curl.go
@@ -8,8 +8,8 @@ import (
|
|||||||
"os/exec"
|
"os/exec"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/urfave/cli/v3"
|
|
||||||
"github.com/nbd-wtf/go-nostr"
|
"github.com/nbd-wtf/go-nostr"
|
||||||
|
"github.com/urfave/cli/v3"
|
||||||
"golang.org/x/exp/slices"
|
"golang.org/x/exp/slices"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -20,6 +20,7 @@ var curl = &cli.Command{
|
|||||||
Usage: "calls curl but with a nip98 header",
|
Usage: "calls curl but with a nip98 header",
|
||||||
Description: "accepts all flags and arguments exactly as they would be passed to curl.",
|
Description: "accepts all flags and arguments exactly as they would be passed to curl.",
|
||||||
Flags: defaultKeyFlags,
|
Flags: defaultKeyFlags,
|
||||||
|
DisableSliceFlagSeparator: true,
|
||||||
Action: func(ctx context.Context, c *cli.Command) error {
|
Action: func(ctx context.Context, c *cli.Command) error {
|
||||||
kr, _, err := gatherKeyerFromArguments(ctx, c)
|
kr, _, err := gatherKeyerFromArguments(ctx, c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
9
dvm.go
9
dvm.go
@@ -16,8 +16,6 @@ import (
|
|||||||
var dvm = &cli.Command{
|
var dvm = &cli.Command{
|
||||||
Name: "dvm",
|
Name: "dvm",
|
||||||
Usage: "deal with nip90 data-vending-machine things (experimental)",
|
Usage: "deal with nip90 data-vending-machine things (experimental)",
|
||||||
Description: `example usage:
|
|
||||||
nak dvm 5001 --input "What is the capital of France?" --input-type text --output "text/plain" --bid 1000 wss://relay.example.com`,
|
|
||||||
DisableSliceFlagSeparator: true,
|
DisableSliceFlagSeparator: true,
|
||||||
Flags: append(defaultKeyFlags,
|
Flags: append(defaultKeyFlags,
|
||||||
&cli.StringSliceFlag{
|
&cli.StringSliceFlag{
|
||||||
@@ -29,6 +27,7 @@ var dvm = &cli.Command{
|
|||||||
{
|
{
|
||||||
Name: "list",
|
Name: "list",
|
||||||
Usage: "find DVMs that have announced themselves for a specific kind",
|
Usage: "find DVMs that have announced themselves for a specific kind",
|
||||||
|
DisableSliceFlagSeparator: true,
|
||||||
Action: func(ctx context.Context, c *cli.Command) error {
|
Action: func(ctx context.Context, c *cli.Command) error {
|
||||||
return fmt.Errorf("we don't know how to do this yet")
|
return fmt.Errorf("we don't know how to do this yet")
|
||||||
},
|
},
|
||||||
@@ -41,6 +40,7 @@ var dvm = &cli.Command{
|
|||||||
if job.InputType != "" {
|
if job.InputType != "" {
|
||||||
flags = append(flags, &cli.StringSliceFlag{
|
flags = append(flags, &cli.StringSliceFlag{
|
||||||
Name: "input",
|
Name: "input",
|
||||||
|
Aliases: []string{"i"},
|
||||||
Category: "INPUT",
|
Category: "INPUT",
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -56,6 +56,7 @@ var dvm = &cli.Command{
|
|||||||
Name: strconv.Itoa(job.InputKind),
|
Name: strconv.Itoa(job.InputKind),
|
||||||
Usage: job.Name,
|
Usage: job.Name,
|
||||||
Description: job.Description,
|
Description: job.Description,
|
||||||
|
DisableSliceFlagSeparator: true,
|
||||||
Flags: flags,
|
Flags: flags,
|
||||||
Action: func(ctx context.Context, c *cli.Command) error {
|
Action: func(ctx context.Context, c *cli.Command) error {
|
||||||
relayUrls := c.StringSlice("relay")
|
relayUrls := c.StringSlice("relay")
|
||||||
@@ -97,6 +98,8 @@ var dvm = &cli.Command{
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logverbose("%s", evt)
|
||||||
|
|
||||||
log("- publishing job request... ")
|
log("- publishing job request... ")
|
||||||
first := true
|
first := true
|
||||||
for res := range sys.Pool.PublishMany(ctx, relayUrls, evt) {
|
for res := range sys.Pool.PublishMany(ctx, relayUrls, evt) {
|
||||||
@@ -117,7 +120,7 @@ var dvm = &cli.Command{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
log("\n- waiting for response...")
|
log("\n- waiting for response...\n")
|
||||||
for ie := range sys.Pool.SubscribeMany(ctx, relayUrls, nostr.Filter{
|
for ie := range sys.Pool.SubscribeMany(ctx, relayUrls, nostr.Filter{
|
||||||
Kinds: []int{7000, job.OutputKind},
|
Kinds: []int{7000, job.OutputKind},
|
||||||
Tags: nostr.TagMap{"e": []string{evt.ID}},
|
Tags: nostr.TagMap{"e": []string{evt.ID}},
|
||||||
|
3
relay.go
3
relay.go
@@ -85,6 +85,8 @@ var relay = &cli.Command{
|
|||||||
Usage: fmt.Sprintf(`the "%s" relay management RPC call`, def.method),
|
Usage: fmt.Sprintf(`the "%s" relay management RPC call`, def.method),
|
||||||
Description: fmt.Sprintf(
|
Description: fmt.Sprintf(
|
||||||
`the "%s" management RPC call, see https://nips.nostr.com/86 for more information`, def.method),
|
`the "%s" management RPC call, see https://nips.nostr.com/86 for more information`, def.method),
|
||||||
|
Flags: flags,
|
||||||
|
DisableSliceFlagSeparator: true,
|
||||||
Action: func(ctx context.Context, c *cli.Command) error {
|
Action: func(ctx context.Context, c *cli.Command) error {
|
||||||
params := make([]any, len(def.args))
|
params := make([]any, len(def.args))
|
||||||
for i, argName := range def.args {
|
for i, argName := range def.args {
|
||||||
@@ -174,7 +176,6 @@ var relay = &cli.Command{
|
|||||||
|
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
Flags: flags,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
commands = append(commands, cmd)
|
commands = append(commands, cmd)
|
||||||
|
Reference in New Issue
Block a user