mirror of
https://github.com/fiatjaf/nak.git
synced 2025-05-01 04:19:56 -04:00
small fixes on dvm flags and stuff.
This commit is contained in:
parent
f5316a0f35
commit
c60bb82be8
11
curl.go
11
curl.go
@ -8,18 +8,19 @@ 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"
|
||||||
)
|
)
|
||||||
|
|
||||||
var curlFlags []string
|
var curlFlags []string
|
||||||
|
|
||||||
var curl = &cli.Command{
|
var curl = &cli.Command{
|
||||||
Name: "curl",
|
Name: "curl",
|
||||||
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 {
|
||||||
|
25
dvm.go
25
dvm.go
@ -14,10 +14,8 @@ 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{
|
||||||
@ -27,8 +25,9 @@ var dvm = &cli.Command{
|
|||||||
),
|
),
|
||||||
Commands: append([]*cli.Command{
|
Commands: append([]*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",
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -53,10 +53,11 @@ var dvm = &cli.Command{
|
|||||||
}
|
}
|
||||||
|
|
||||||
commands[i] = &cli.Command{
|
commands[i] = &cli.Command{
|
||||||
Name: strconv.Itoa(job.InputKind),
|
Name: strconv.Itoa(job.InputKind),
|
||||||
Usage: job.Name,
|
Usage: job.Name,
|
||||||
Description: job.Description,
|
Description: job.Description,
|
||||||
Flags: flags,
|
DisableSliceFlagSeparator: true,
|
||||||
|
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")
|
||||||
relays := connectToAllRelays(ctx, relayUrls, false)
|
relays := connectToAllRelays(ctx, relayUrls, false)
|
||||||
@ -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)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user