nak/main.go

61 lines
1.1 KiB
Go
Raw Permalink Normal View History

2023-05-03 15:24:52 -04:00
package main
import (
2024-06-25 21:18:26 -04:00
"context"
2023-05-03 15:24:52 -04:00
"os"
"github.com/fiatjaf/cli/v3"
2023-05-03 15:24:52 -04:00
)
2024-09-15 07:57:53 -04:00
var version string = "debug"
2024-06-25 21:18:26 -04:00
var app = &cli.Command{
Name: "nak",
Suggest: true,
UseShortOptionHandling: true,
AllowFlagsAfterArguments: true,
Usage: "the nostr army knife command-line tool",
DisableSliceFlagSeparator: true,
2023-11-08 20:26:41 -05:00
Commands: []*cli.Command{
req,
count,
fetch,
event,
decode,
encode,
key,
2023-11-08 20:26:41 -05:00
verify,
2023-11-20 13:00:50 -05:00
relay,
2023-12-09 14:37:47 -05:00
bunker,
2024-08-19 11:43:22 -04:00
serve,
encrypt,
decrypt,
2023-11-08 20:26:41 -05:00
},
2024-09-15 07:57:53 -04:00
Version: version,
Flags: []cli.Flag{
&cli.BoolFlag{
2024-07-13 08:42:43 -04:00
Name: "quiet",
Usage: "do not print logs and info messages to stderr, use -qq to also not print anything to stdout",
Aliases: []string{"q"},
Persistent: true,
2024-06-25 21:18:26 -04:00
Action: func(ctx context.Context, c *cli.Command, b bool) error {
q := c.Count("quiet")
if q >= 1 {
log = func(msg string, args ...any) {}
if q >= 2 {
2024-08-19 11:43:22 -04:00
stdout = func(_ ...any) (int, error) { return 0, nil }
}
}
return nil
},
},
},
2023-11-08 20:26:41 -05:00
}
2023-05-03 15:24:52 -04:00
2023-11-08 20:26:41 -05:00
func main() {
2024-06-25 21:18:26 -04:00
if err := app.Run(context.Background(), os.Args); err != nil {
stdout(err)
2023-05-03 17:14:06 -04:00
os.Exit(1)
2023-05-03 15:24:52 -04:00
}
}