Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions cmd/writeas/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
},
},
{
Expand Down
23 changes: 14 additions & 9 deletions commands/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -408,23 +408,28 @@ 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)
}
// Take password from argument, and fall back to input
pass := c.String("p")
if pass == "" {
fmt.Print("Password: ")
enteredPass, 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)
// Validate password
if len(enteredPass) == 0 {
return cli.NewExitError("Please enter your password.", 1)
}
pass = string(enteredPass)
}

if config.IsTor(c) {
log.Info(c, "Logging in via hidden service...")
} else {
log.Info(c, "Logging in...")
}
err = api.DoLogIn(c, username, string(pass))
err = api.DoLogIn(c, username, pass)
if err != nil {
return cli.NewExitError(fmt.Sprintf("error logging in: %v", err), 1)
}
Expand Down