nak/main.go

52 lines
897 B
Go
Raw Normal View History

2023-05-03 15:24:52 -04:00
package main
import (
"os"
"github.com/urfave/cli/v2"
)
var q int
2023-11-08 20:26:41 -05:00
var app = &cli.App{
2024-01-21 16:11:52 -05:00
Name: "nak",
Suggest: true,
UseShortOptionHandling: true,
Usage: "the nostr army knife command-line tool",
2023-11-08 20:26:41 -05:00
Commands: []*cli.Command{
req,
count,
fetch,
event,
decode,
encode,
verify,
2023-11-20 13:00:50 -05:00
relay,
2023-12-09 14:37:47 -05:00
bunker,
2023-11-08 20:26:41 -05:00
},
Flags: []cli.Flag{
&cli.BoolFlag{
Name: "quiet",
Usage: "do not print logs and info messages to stderr, use -qq to also not print anything to stdout",
Count: &q,
Aliases: []string{"q"},
Action: func(ctx *cli.Context, b bool) error {
if q >= 1 {
log = func(msg string, args ...any) {}
if q >= 2 {
stdout = func(a ...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() {
2023-05-03 15:24:52 -04:00
if err := app.Run(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
}
}