File: gresource

package info (click to toggle)
glib2.0 2.86.3-5
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 67,020 kB
  • sloc: ansic: 544,698; python: 9,702; sh: 1,612; xml: 1,482; perl: 1,222; cpp: 535; makefile: 308; javascript: 11
file content (79 lines) | stat: -rw-r--r-- 2,188 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#
# Copyright 2012 Red Hat, Inc.
#
# This library is free software; you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as
# published by the Free Software Foundation; either version 2.1 of the
# licence, or (at your option) any later version.
#
# This is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
# License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this library; if not, see <http://www.gnu.org/licenses/>.
#
# SPDX-License-Identifier: LGPL-2.1-or-later

# shellcheck shell=bash

# Check for bash
[ -z "$BASH_VERSION" ] && return

####################################################################################################

__gresource() {
  local choices coffset gresource_binary
  gresource_binary="$1"

  if [ "${COMP_CWORD}" -gt 2 ]; then
      if [ "${COMP_WORDS[1]}" = --section ]; then
          coffset=2
      else
          coffset=0
      fi
  else
      coffset=0
  fi

  case "$((COMP_CWORD-coffset))" in
    1)
      choices=$'--section \nhelp \nsections \nlist \ndetails \nextract '
      ;;

    2)
      case "${COMP_WORDS[$((coffset+1))]}" in
        --section)
          return 0
          ;;

        help)
          choices=$'sections\nlist\ndetails\nextract'
          ;;

        sections|list|details|extract)
          # shellcheck disable=SC2207
          COMPREPLY=($(compgen -f -- "${COMP_WORDS[${COMP_CWORD}]}"))
          return 0
          ;;
      esac
      ;;

    3)
      case "${COMP_WORDS[$((coffset+1))]}" in
        list|details|extract)
          choices="$("$gresource_binary" list "${COMP_WORDS[$((coffset+2))]}" 2> /dev/null | sed -e 's.$. .')"
          ;;
      esac
      ;;
  esac

  local IFS=$'\n'
  # shellcheck disable=SC2207
  COMPREPLY=($(compgen -W "${choices}" -- "${COMP_WORDS[${COMP_CWORD}]}"))
}

####################################################################################################

complete -o nospace -F __gresource gresource