python-manilaclient/tools/manila.bash_completion
Eric Harney 6ecdbef0fc Re-enable shell completion cache
This enables writing ids to a local completion
cache when using the manilaclient shell, which
allows tools/manila.bash_completion to complete
commands such as:
    manila delete a<tab>

Share ids are recorded on "manila list" operations.

Caching can be expanded to cover additional
types of manila objects using this same infrastructure.

Uses ~/.cache/manilaclient/ to match path standards,
and uses SHA-1 since Python running w/ FIPS mode may
not have MD5.

Also, fix a small bug in the fakes used in our test suite.
We were adding the shares count (an optional param) to all
the list responses, while this is something that should be done
only if the param with_count is set to True.

Co-Authored-By: Victoria Martinez de la Cruz <victoria@redhat.com>
Closes-Bug: #1712835
Change-Id: I7f4dedf1dd4b7db6cf24fc1c4ed2a8d3685f714c
2021-07-19 17:44:07 +00:00

16 lines
367 B
Plaintext

_manila()
{
local cur prev opts
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
opts="$(manila bash_completion)"
COMPLETION_CACHE=~/.cache/manilaclient/*/*-cache
opts+=" "$(cat $COMPLETION_CACHE 2> /dev/null | tr '\n' ' ')
COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
}
complete -F _manila manila