/
cli.go
32 lines (26 loc) · 958 Bytes
/
cli.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package main
import (
"log/slog"
"time"
)
type CLI struct {
Version versionCmd `cmd:"" help:"Show version information"`
Check checkConnectionCmd `cmd:"" default:"1" help:"Check connection to redis (default command)"`
Addr string `default:"localhost:6379" short:"a" help:"Address to connect to in the form host:port"`
Password string `default:"" short:"p" help:"Redis password"`
DialTimeout time.Duration `default:"5s" help:"Set DialTimout"`
ReadTimeout time.Duration `default:"3s" help:"Set ReadTimeout"`
TLS bool `help:"Connect to a TLS enabled Redis"`
SkipVerify bool `short:"x" help:"Insecure! Accepty every certificate"`
}
type versionCmd struct {
Version string
}
func (c *versionCmd) Run() error {
slog.Info(Version)
return nil
}
type checkConnectionCmd struct{}
func (c *checkConnectionCmd) Run() error {
return checkConnection()
}