benkehoe / aws-sso-util

Smooth out the rough edges of AWS SSO (temporarily, until AWS makes it better).
Apache License 2.0
953 stars 72 forks source link

Shell completion (Bash) #98

Closed yermulnik closed 1 year ago

yermulnik commented 1 year ago

I'm looking into adding Bash completion locally. Per the https://github.com/benkehoe/aws-sso-util#quickstart the "main" command to produce shell completion code is _AWS_SSO_UTIL_COMPLETE=source_bash aws-sso-util, which I don't know why produces empty output for me — is this expected/known or did I manage to tangle my local setup somehow?

aws-sso-util is installed via Homebrew and OS is Ubuntu Jammy if it might be important:

> brew info aws-sso-util
==> aws-sso-util: stable 4.31.0 (bottled), HEAD
Smooth out the rough edges of AWS SSO (temporarily, until AWS makes it better)
https://github.com/benkehoe/aws-sso-util
/home/linuxbrew/.linuxbrew/Cellar/aws-sso-util/4.31.0 (3,103 files, 99.5MB) *
  Poured from bottle using the formulae.brew.sh API on 2023-01-27 at 17:00:56
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/aws-sso-util.rb
License: Apache-2.0
==> Dependencies
Required: python@3.11 ✔, six ✔
==> Options
--HEAD
        Install HEAD version
==> Analytics
install: 41 (30 days), 21 (90 days), 5,038 (365 days)
install-on-request: 41 (30 days), 20 (90 days), 4,988 (365 days)
build-error: 0 (30 days)

> lsb_release -d
Description:    Ubuntu 22.04.2 LTS

> _AWS_SSO_UTIL_COMPLETE=source_bash aws-sso-util | wc -l
0

Appreciate any help.

benkehoe commented 1 year ago

I'm afraid I can't be of much help directly; shell completion is a feature of click, the CLI library. The docs for completion are here: https://click.palletsprojects.com/en/8.1.x/shell-completion/ let me know if you do or don't make progress!

yermulnik commented 1 year ago

@benkehoe Does this mean that _AWS_SSO_UTIL_COMPLETE=source_bash aws-sso-util does produce non-empty output to you?

benkehoe commented 1 year ago

Aha: I missed updating the documentation. In click 8 (which aws-sso-util requires as of v4.31), the value changed from source_bash to bash_source (and similar for other shells) (no idea why). It was working for me using the click 8 docs, but the links in the README here and the example were using the click 7 version.

yermulnik commented 1 year ago

@benkehoe Worked like a charm! Thanks a lot for looking into this!