From b5bfe16c10cb365ee92d4f2230d4e407cc5f648a Mon Sep 17 00:00:00 2001 From: Stan Putrya Date: Sat, 26 Aug 2017 23:02:08 +0300 Subject: [PATCH 1/2] Add interactive password input --- go/cmd/ccql/main.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/go/cmd/ccql/main.go b/go/cmd/ccql/main.go index 288f29d..a153997 100644 --- a/go/cmd/ccql/main.go +++ b/go/cmd/ccql/main.go @@ -6,10 +6,12 @@ import ( "log" "os" "os/user" + "syscall" "github.com/github/ccql/go/logic" "github.com/github/ccql/go/sql" "github.com/github/ccql/go/text" + "golang.org/x/crypto/ssh/terminal" golib_log "github.com/outbrain/golib/log" "gopkg.in/gcfg.v1" @@ -35,6 +37,7 @@ func main() { help := flag.Bool("help", false, "Display usage") user := flag.String("u", osUser, "MySQL username") password := flag.String("p", "", "MySQL password") + askPassword := flag.Bool("P", false, "Ask mySQL password") credentialsFile := flag.String("C", "", "Credentials file, expecting [client] scope, with 'user', 'password' fields. Overrides -u and -p") defaultSchema := flag.String("d", "information_schema", "Default schema to use") hostsList := flag.String("h", "", "Comma or space delimited list of hosts in hostname[:port] format. If not given, hosts read from stdin") @@ -105,6 +108,15 @@ func main() { } } + if *askPassword { + fmt.Print("Mysql password: ") + passwd, err := terminal.ReadPassword(int(syscall.Stdin)) + if err != nil { + log.Fatalf("\nError while get password:", err) + } + *password = string(passwd) + } + if err := logic.QueryHosts(hosts, *user, *password, *defaultSchema, queries, *maxConcurrency, *timeout); err != nil { os.Exit(1) } From a9aa564b882969fcc08e44788fe018bd08481235 Mon Sep 17 00:00:00 2001 From: Stan Putrya Date: Sun, 27 Aug 2017 13:34:52 +0300 Subject: [PATCH 2/2] Change -P option to -ask-pass --- go/cmd/ccql/main.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go/cmd/ccql/main.go b/go/cmd/ccql/main.go index a153997..ec2c02a 100644 --- a/go/cmd/ccql/main.go +++ b/go/cmd/ccql/main.go @@ -37,7 +37,7 @@ func main() { help := flag.Bool("help", false, "Display usage") user := flag.String("u", osUser, "MySQL username") password := flag.String("p", "", "MySQL password") - askPassword := flag.Bool("P", false, "Ask mySQL password") + askPassword := flag.Bool("ask-pass", false, "prompt for MySQL password") credentialsFile := flag.String("C", "", "Credentials file, expecting [client] scope, with 'user', 'password' fields. Overrides -u and -p") defaultSchema := flag.String("d", "information_schema", "Default schema to use") hostsList := flag.String("h", "", "Comma or space delimited list of hosts in hostname[:port] format. If not given, hosts read from stdin")