mirror of
https://github.com/fiatjaf/nak.git
synced 2025-04-22 09:29: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"
|
||||
"strings"
|
||||
|
||||
"github.com/urfave/cli/v3"
|
||||
"github.com/nbd-wtf/go-nostr"
|
||||
"github.com/urfave/cli/v3"
|
||||
"golang.org/x/exp/slices"
|
||||
)
|
||||
|
||||
var curlFlags []string
|
||||
|
||||
var curl = &cli.Command{
|
||||
Name: "curl",
|
||||
Usage: "calls curl but with a nip98 header",
|
||||
Description: "accepts all flags and arguments exactly as they would be passed to curl.",
|
||||
Flags: defaultKeyFlags,
|
||||
Name: "curl",
|
||||
Usage: "calls curl but with a nip98 header",
|
||||
Description: "accepts all flags and arguments exactly as they would be passed to curl.",
|
||||
Flags: defaultKeyFlags,
|
||||
DisableSliceFlagSeparator: true,
|
||||
Action: func(ctx context.Context, c *cli.Command) error {
|
||||
kr, _, err := gatherKeyerFromArguments(ctx, c)
|
||||
if err != nil {
|
||||
|
25
dvm.go
25
dvm.go
@ -14,10 +14,8 @@ import (
|
||||
)
|
||||
|
||||
var dvm = &cli.Command{
|
||||
Name: "dvm",
|
||||
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`,
|
||||
Name: "dvm",
|
||||
Usage: "deal with nip90 data-vending-machine things (experimental)",
|
||||
DisableSliceFlagSeparator: true,
|
||||
Flags: append(defaultKeyFlags,
|
||||
&cli.StringSliceFlag{
|
||||
@ -27,8 +25,9 @@ var dvm = &cli.Command{
|
||||
),
|
||||
Commands: append([]*cli.Command{
|
||||
{
|
||||
Name: "list",
|
||||
Usage: "find DVMs that have announced themselves for a specific kind",
|
||||
Name: "list",
|
||||
Usage: "find DVMs that have announced themselves for a specific kind",
|
||||
DisableSliceFlagSeparator: true,
|
||||
Action: func(ctx context.Context, c *cli.Command) error {
|
||||
return fmt.Errorf("we don't know how to do this yet")
|
||||
},
|
||||
@ -41,6 +40,7 @@ var dvm = &cli.Command{
|
||||
if job.InputType != "" {
|
||||
flags = append(flags, &cli.StringSliceFlag{
|
||||
Name: "input",
|
||||
Aliases: []string{"i"},
|
||||
Category: "INPUT",
|
||||
})
|
||||
}
|
||||
@ -53,10 +53,11 @@ var dvm = &cli.Command{
|
||||
}
|
||||
|
||||
commands[i] = &cli.Command{
|
||||
Name: strconv.Itoa(job.InputKind),
|
||||
Usage: job.Name,
|
||||
Description: job.Description,
|
||||
Flags: flags,
|
||||
Name: strconv.Itoa(job.InputKind),
|
||||
Usage: job.Name,
|
||||
Description: job.Description,
|
||||
DisableSliceFlagSeparator: true,
|
||||
Flags: flags,
|
||||
Action: func(ctx context.Context, c *cli.Command) error {
|
||||
relayUrls := c.StringSlice("relay")
|
||||
relays := connectToAllRelays(ctx, relayUrls, false)
|
||||
@ -97,6 +98,8 @@ var dvm = &cli.Command{
|
||||
return err
|
||||
}
|
||||
|
||||
logverbose("%s", evt)
|
||||
|
||||
log("- publishing job request... ")
|
||||
first := true
|
||||
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{
|
||||
Kinds: []int{7000, job.OutputKind},
|
||||
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),
|
||||
Description: fmt.Sprintf(
|
||||
`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 {
|
||||
params := make([]any, len(def.args))
|
||||
for i, argName := range def.args {
|
||||
@ -174,7 +176,6 @@ var relay = &cli.Command{
|
||||
|
||||
return nil
|
||||
},
|
||||
Flags: flags,
|
||||
}
|
||||
|
||||
commands = append(commands, cmd)
|
||||
|
Loading…
x
Reference in New Issue
Block a user