nak event --confirm

This commit is contained in:
fiatjaf
2025-05-03 21:44:59 -03:00
parent f98bd7483f
commit 02f22a8c2f
2 changed files with 61 additions and 0 deletions

View File

@@ -129,6 +129,11 @@ example:
Value: nostr.Now(),
Category: CATEGORY_EVENT_FIELDS,
},
&cli.BoolFlag{
Name: "confirm",
Usage: "ask before publishing the event",
Category: CATEGORY_EXTRAS,
},
),
ArgsUsage: "[relay...]",
Action: func(ctx context.Context, c *cli.Command) error {
@@ -314,6 +319,17 @@ example:
if len(relays) > 0 {
os.Stdout.Sync()
if c.Bool("confirm") {
relaysStr := make([]string, len(relays))
for i, r := range relays {
relaysStr[i] = strings.ToLower(strings.Split(r.URL, "://")[1])
}
time.Sleep(time.Millisecond * 10)
if !askConfirmation("publish to [ " + strings.Join(relaysStr, " ") + " ]? ") {
return nil
}
}
if supportsDynamicMultilineMagic() {
// overcomplicated multiline rendering magic
ctx, cancel := context.WithTimeout(ctx, 10*time.Second)