Skip to content

Commit

Permalink
Fix autocompletion of profile names. Fixes #506
Browse files Browse the repository at this point in the history
  • Loading branch information
mtibben committed Feb 10, 2020
1 parent 0b449e7 commit e05eb98
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion cli/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func ConfigureExecCommand(app *kingpin.Application) {

cmd.Arg("profile", "Name of the profile").
Required().
HintAction(awsConfigFile.ProfileNames).
HintAction(getProfileNames).
StringVar(&input.ProfileName)

cmd.Arg("cmd", "Command to execute, defaults to $SHELL").
Expand Down
10 changes: 7 additions & 3 deletions cli/global.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,10 @@ func ConfigureGlobals(app *kingpin.Application) {
return err
}
}
if awsConfigFile == nil {
awsConfigFile, err = vault.LoadConfigFromEnv()
}

awsConfigFile, err = vault.LoadConfigFromEnv()
configLoader = &vault.ConfigLoader{File: awsConfigFile}

return err
})
}
Expand All @@ -120,3 +120,7 @@ func fileKeyringPassphrasePrompt(prompt string) (string, error) {
fmt.Println()
return string(b), nil
}

func getProfileNames() []string {
return awsConfigFile.ProfileNames()
}
2 changes: 1 addition & 1 deletion cli/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func ConfigureLoginCommand(app *kingpin.Application) {

cmd.Arg("profile", "Name of the profile").
Required().
HintAction(awsConfigFile.ProfileNames).
HintAction(getProfileNames).
StringVar(&input.ProfileName)

cmd.Action(func(c *kingpin.ParseContext) error {
Expand Down
2 changes: 1 addition & 1 deletion cli/rm.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ func ConfigureRemoveCommand(app *kingpin.Application) {

cmd.Arg("profile", "Name of the profile").
Required().
HintAction(awsConfigFile.ProfileNames).
HintAction(getProfileNames).
StringVar(&input.ProfileName)

cmd.Flag("sessions-only", "Only remove sessions, leave credentials intact").
Expand Down
2 changes: 1 addition & 1 deletion cli/rotate.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func ConfigureRotateCommand(app *kingpin.Application) {

cmd.Arg("profile", "Name of the profile").
Required().
HintAction(awsConfigFile.ProfileNames).
HintAction(getProfileNames).
StringVar(&input.ProfileName)

cmd.Action(func(c *kingpin.ParseContext) error {
Expand Down

0 comments on commit e05eb98

Please sign in to comment.