From c6af292b2a96a34eaa7176cb7ba27af5460d3b76 Mon Sep 17 00:00:00 2001 From: Christopher Davis Date: Thu, 5 Sep 2019 17:23:30 -0700 Subject: [PATCH] Add password flag for authentication For T692 --- cmd/writeas/main.go | 4 ++++ commands/commands.go | 20 ++++++++++++-------- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/cmd/writeas/main.go b/cmd/writeas/main.go index e9c1019..40bff74 100644 --- a/cmd/writeas/main.go +++ b/cmd/writeas/main.go @@ -238,6 +238,10 @@ func main() { Name: "verbose, v", Usage: "Make the operation more talkative", }, + cli.StringFlag{ + Name: "password, p", + Usage: "The password for the account being logged into", + }, }, }, { diff --git a/commands/commands.go b/commands/commands.go index 29ddc21..c2fc3a8 100644 --- a/commands/commands.go +++ b/commands/commands.go @@ -408,15 +408,19 @@ func CmdAuth(c *cli.Context) error { } } - fmt.Print("Password: ") - pass, err := gopass.GetPasswdMasked() - if err != nil { - return cli.NewExitError(fmt.Sprintf("error reading password: %v", err), 1) - } - - // Validate password + // Take password from argument, and fall back to input + pass := c.String("p") if len(pass) == 0 { - return cli.NewExitError("Please enter your password.", 1) + fmt.Print("Password: ") + pass, err := gopass.GetPasswdMasked() + if err != nil { + return cli.NewExitError(fmt.Sprintf("error reading password: %v", err), 1) + } + + // Validate password + if len(pass) == 0 { + return cli.NewExitError("Please enter your password.", 1) + } } if config.IsTor(c) {