add password cmdline param

master
Jordan Orelli 11 years ago
parent 68045628a0
commit b855c321ac

@ -14,6 +14,7 @@ import (
var options struct { var options struct {
host string host string
port int port int
password string
} }
func usage(status int) { func usage(status int) {
@ -45,6 +46,10 @@ func main() {
} }
defer conn.Close() defer conn.Close()
if options.password != "" {
fmt.Fprintf(conn, "*2\r\n$4\r\nauth\r\n$%d\r\n%s\r\n", len(options.password), options.password)
}
f, err := os.Open(fname) f, err := os.Open(fname)
if err != nil { if err != nil {
fmt.Printf("unable to open file %s: %v\n", fname, err) fmt.Printf("unable to open file %s: %v\n", fname, err)
@ -85,6 +90,7 @@ func main() {
func init() { func init() {
flag.StringVar(&options.host, "h", "127.0.0.1", "hostname") flag.StringVar(&options.host, "h", "127.0.0.1", "hostname")
flag.IntVar(&options.port, "p", 6379, "port") flag.IntVar(&options.port, "p", 6379, "port")
flag.StringVar(&options.password, "a", "", "password")
} }
/* /*

Loading…
Cancel
Save