• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1
2# Check for bash
3[ -z "$BASH_VERSION" ] && return
4
5####################################################################################################
6
7__gresource() {
8  local choices coffset section
9
10  if [ ${COMP_CWORD} -gt 2 ]; then
11      if [ ${COMP_WORDS[1]} = --section ]; then
12          section=${COMP_WORDS[2]}
13          coffset=2
14      else
15          coffset=0
16      fi
17  else
18      coffset=0
19  fi
20
21  case "$((${COMP_CWORD}-$coffset))" in
22    1)
23      choices=$'--section \nhelp \nsections \nlist \ndetails \nextract '
24      ;;
25
26    2)
27      case "${COMP_WORDS[$(($coffset+1))]}" in
28        --section)
29          return 0
30          ;;
31
32        help)
33          choices=$'sections\nlist\ndetails\nextract'
34          ;;
35
36        sections|list|details|extract)
37          COMPREPLY=($(compgen -f -- ${COMP_WORDS[${COMP_CWORD}]}))
38          return 0
39          ;;
40      esac
41      ;;
42
43    3)
44      case "${COMP_WORDS[$(($coffset+1))]}" in
45        list|details|extract)
46          choices="$(gresource list ${COMP_WORDS[$(($coffset+2))]} 2> /dev/null | sed -e 's.$. .')"
47          ;;
48      esac
49      ;;
50  esac
51
52  local IFS=$'\n'
53  COMPREPLY=($(compgen -W "${choices}" -- "${COMP_WORDS[${COMP_CWORD}]}"))
54}
55
56####################################################################################################
57
58complete -o nospace -F __gresource gresource
59