瀏覽代碼

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
pull/36/head
Rob Loranger 4 年之前
父節點
當前提交
44501a2e8c
沒有發現已知的金鑰在資料庫的簽署中 GPG 金鑰 ID: D6F1633A4F0903B8
共有 1 個檔案被更改,包括 10 行新增2 行删除
  1. +10
    -2
      commands/commands.go

+ 10
- 2
commands/commands.go 查看文件

@@ -368,9 +368,17 @@ func CmdAuth(c *cli.Context) error {
}

// Validate arguments and get password
// TODO: after global config, check for default user
if username == "" {
return cli.NewExitError("usage: "+executable.Name()+" auth <username>", 1)
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: ")


Loading…
取消
儲存