summaryrefslogtreecommitdiffstats
path: root/subprojects/extensions-tool/completion/bash/gnome-extensions
blob: 05cd039269a5920cf4821118cd9413b3706641ea (plain)
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
80
81
82
83
84
85
86
87
88
89
90
91
# Check for bash
[ -z "$BASH_VERSION" ] && return

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

__gnome_extensions() {
  local commands="version enable disable reset info install show list create pack prefs uninstall"
  local COMMAND=${COMP_WORDS[1]}

  _init_completion -s || return

  case "${COMP_CWORD}" in
    1)
      COMPREPLY=($(compgen -W "help $commands" -- "$2"))
      return 0
      ;;

    2)
      case "$COMMAND" in
        help)
          COMPREPLY=($(compgen -W "$commands" -- "$2"))
          return 0
          ;;

        disable)
          local list_opt=--enabled
          ;;&
        enable)
          local list_opt=--disabled
          ;;&
        prefs)
          local list_opt=--prefs
          ;;&
        uninstall)
          local list_opt=--user
          ;;&
        enable|disable|info|show|prefs|reset|uninstall)
          COMPREPLY=($(compgen -W "`gnome-extensions list $list_opt`" -- "$2"))
          return 0
          ;;
      esac
      ;;
  esac

  case "$COMMAND" in
    create)
      case "$prev" in
        --template)
          COMPREPLY=($(compgen -W "`gnome-extensions create --list-templates`" -- "$2"))
          return 0
          ;;
      esac
      ;;
    pack)
      case "$prev" in
        --podir|--out-dir|-o)
          _filedir -d
          return 0
          ;;
        --schema)
          _filedir gschema.xml
          return 0
          ;;
        --extra-source)
          _filedir
          return 0
          ;;
      esac
      ;;
    install)
      if [[ $cur != -* ]]
      then
          _filedir zip
          return 0
      fi
      ;;
  esac

  # Stop if we are currently waiting for an option value
  $split && return

  # Otherwise, get the supported options for ${COMMAND} (if any)
  COMPREPLY=($(compgen -W "$(_parse_help $1 "help $COMMAND")" -- "$2"))
  [[ $COMPREPLY == *= ]] && compopt -o nospace
  return 0
}

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

complete -F __gnome_extensions gnome-extensions