1 # bash completion for Why3
3 # To use this script you should have bash-completion package installed
4 # Put it in /etc/bash_completion.d or just source it from your .bashrc
8 local cur prev words cword split
10 if declare -F _init_completion > /dev/null ; then
11 _init_completion -s || return
13 _get_comp_words_by_ref -n = cur prev words cword
18 # this only completes the first '-T' option
19 # also, we cannot complete library theories
20 ${split:-false} || cword=$((cword-1))
21 words=("${words[@]:0:$cword}" --print-namespace)
22 theories=$(${words[@]} 2>/dev/null | sed -n -e 's/^\([^ ][^-]*\).*/\1/p')
23 COMPREPLY=( $( compgen -W "$theories" -- "$cur" ) )
27 ${split:-false} || cword=$((cword-1))
28 words=("${words[@]:0:$cword}" --print-namespace)
29 goals=$(${words[@]} 2>/dev/null | sed -n -e 's/.*-goal //p')
30 COMPREPLY=( $( compgen -W "$goals" -- "$cur" ) )
33 -C|--config|--extra-config)
42 provers=$($1 config list-provers | sed -n -e 's/^\([^ ]\+\).*/\1/p' | uniq)
43 COMPREPLY=( $( compgen -W "$provers" -- "$cur" ) )
47 formats=$($1 show formats | sed -n -e 's/^\([^ ]\+\).*/\1/p')
48 COMPREPLY=( $( compgen -W "$formats" -- "$cur" ) )
51 -t|--timelimit|-m|--memlimit)
55 transforms=$($1 show transformations | grep -e '^ [^ ]')
56 COMPREPLY=( $( compgen -W "$transforms" -- "$cur" ) )
60 metas=$($1 show metas |
61 grep -e '^[^ ]\+\( (flag)\)\?\( \[string\]\)\?$' |
62 sed -e 's/ (flag)//;s/ \[string\]/=/')
63 COMPREPLY=( $( compgen -W "$metas" -- "$cur") )
79 ids=$($1 config list-supported-provers)
80 COMPREPLY=( $( compgen -W "$ids" -- "$cur") )
84 COMPREPLY=( $( compgen -W 'none top deep' -- "$cur" ) )
88 flags=$($1 --list-debug-flags | sed -n -e 's/^\([^ ]\+\).*/\1/p')
89 COMPREPLY=( $( compgen -W "$flags" -- "$cur" ) )
93 provers=$($1 config list-provers | sed -n -e 's/^\([^ ]\+\).*/\1/p' | uniq)
94 COMPREPLY=( $( compgen -W "$provers" -- "$cur" ) )
97 --filter-obsolete|--filter-archived|--filter-verified-goal|--filter-verified)
98 COMPREPLY=( $( compgen -W 'yes no all' -- "$cur" ) )
102 COMPREPLY=( $( compgen -W 'simpletree table' -- "$cur" ) )
106 cmds=$($1 $prev --help | sed -n -e 's/^ \([^ ]\+\).*/\1/p')
107 COMPREPLY=( $( compgen -W "$cmds --help -h" -- "$cur" ) )
113 -*) words[cword]="--help"
114 opts=$(_parse_help "${words[@]}")
115 COMPREPLY=( $( compgen -W "$opts" -- "$cur" ) )
116 [[ $COMPREPLY == *= ]] && compopt -o nospace
121 if [ $cword -eq 1 ] ; then
122 cmds=$($1 --help 2>&1 | sed -n -e 's/^ \([a-z]\+\).*/\1/p')
123 COMPREPLY=( $( compgen -W "$cmds" -- "$cur" ) )
129 } && complete -F _why3 why3 why3.opt why3.byte