wflinfo: bash-completion: don't quite in [[
[mesa-waffle.git] / shell-completion / bash / wflinfo
blobb3960f9efb270fcb8fe143510bc74c4e659579ee
1 # Formatted using:
2 # shfmt --language-dialect bash --indent 4 --func-next-line
3 _wflinfo()
5     # long/short opt pairs
6     local -A opts=(
7         ['platform']='p'
8         ['api']='a'
9         ['version']='V'
10         ['profile']=''
11         ['verbose']='v'
12         ['forward-compatible']=''
13         ['debug-context']=''
14         ['robust-context']=''
15         ['reset-notification']=''
16         ['format']='f'
17         ['help']='h'
18     )
20     local cur prev
21     _get_comp_words_by_ref cur prev
23     case $prev in
24     -p | --platform)
25         COMPREPLY=($(compgen -W 'android cgl gbm glx surfaceless_egl sl wayland wgl x11_egl' -- "$cur"))
26         return
27         ;;
28     -a | --api)
29         COMPREPLY=($(compgen -W 'gl gles1 gles2 gles3' -- "$cur"))
30         return
31         ;;
32     -V | --version)
33         local versions=(1.{0..5} 2.{0..1} 3.{0..3} 4.{0..6})
34         COMPREPLY=($(compgen -W "${versions[*]}" -- "$cur"))
35         return
36         ;;
37     --profile)
38         COMPREPLY=($(compgen -W 'core compat none' -- "$cur"))
39         return
40         ;;
41     -f | --format)
42         COMPREPLY=($(compgen -W 'original json' -- "$cur"))
43         return
44         ;;
45     esac
47     if [[ $cur == --* ]]; then
48         COMPREPLY=($(compgen -P '--' -W "${!opts[*]}" -- "${cur:2}"))
49     elif [[ $cur == -* && ${#cur} -gt 1 ]]; then
50         COMPREPLY=($(compgen -P '-' -W "${opts[*]}" -- "${cur:1}"))
51     else
52         COMPREPLY=($(compgen -P '-' -W "${opts[*]}" -- "${cur:1}")
53         $(compgen -P '--' -W "${!opts[*]}" -- "${cur:2}"))
54     fi
55 } &&
56     complete -F _wflinfo wflinfo