mirror of
https://github.com/writeas/writeas-cli
synced 2025-07-26 23:08:16 +00:00
use default user when authenticating
if both a user and host are configured, the command auth should assume that user and host when none specified
This commit is contained in:
parent
836eea7dab
commit
44501a2e8c
@ -368,10 +368,18 @@ func CmdAuth(c *cli.Context) error {
|
||||
}
|
||||
|
||||
// Validate arguments and get password
|
||||
// TODO: after global config, check for default user
|
||||
if username == "" {
|
||||
cfg, err := config.LoadConfig(config.UserDataDir(c.App.ExtraInfo()["configDir"]))
|
||||
if err != nil {
|
||||
return cli.NewExitError(fmt.Sprintf("Failed to load config: %v", err), 1)
|
||||
}
|
||||
if cfg.Default.Host != "" && cfg.Default.User != "" {
|
||||
username = cfg.Default.User
|
||||
fmt.Printf("No user provided, using default user %s for host %s...\n", cfg.Default.User, cfg.Default.Host)
|
||||
} else {
|
||||
return cli.NewExitError("usage: "+executable.Name()+" auth <username>", 1)
|
||||
}
|
||||
}
|
||||
|
||||
fmt.Print("Password: ")
|
||||
pass, err := gopass.GetPasswdMasked()
|
||||
|
Loading…
Reference in New Issue
Block a user