Skip to content

Commit

Permalink
Merge pull request #137 from synfinatic/fix-arn-autocomplete
Browse files Browse the repository at this point in the history
Fix autocomplete for `-a <arn>`
  • Loading branch information
synfinatic authored Nov 16, 2021
2 parents 7000e59 + 5e26376 commit 5e6e5ac
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

* Fix missing --url-action and --browser #113
* Don't print out URL when sending to browser/clipboard for security
* Escape colon in ARN's for `-a` flag to work around the colon being a
word delimiter for bash (auto)complete. #135

## [v1.3.0] - 2021-11-14

Expand Down
11 changes: 10 additions & 1 deletion cmd/complete.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ package main

import (
"io/ioutil"
"strings"

"github.com/goccy/go-yaml"
"github.com/posener/complete"
Expand Down Expand Up @@ -111,7 +112,15 @@ func (p *Predictor) RoleComplete() complete.Predictor {

// ArnComplete returns a list of all the valid AWS Role ARNs we have in the cache
func (p *Predictor) ArnComplete() complete.Predictor {
return complete.PredictSet(p.arns...)
arns := []string{}

// The `:` character is considered a word delimiter by bash complete
// so we need to escape them
for _, a := range p.arns {
arns = append(arns, strings.ReplaceAll(a, ":", "\\:"))
}

return complete.PredictSet(arns...)
}

// RegionsComplete returns a list of all the valid AWS Regions
Expand Down

0 comments on commit 5e6e5ac

Please sign in to comment.