.bash_completion.d/winget
author Oleksandr Gavenko <gavenkoa@gmail.com>
Sun, 12 Nov 2023 23:22:11 +0200
changeset 1028 20761b40404f
parent 1001 b4df956c3d52
permissions -rw-r--r--
Helper to unpack mini TAR on Ansible managed remote hosts.

# -*- mode: sh; sh-shell-file: bash -*-


_winget() {
  local tasks='install  (Installs the given package)
show     (Shows information about a package)
source   (Manage sources of packages)
search   (Find and show basic info of packages)
list     (Display installed packages)
upgrade  (Upgrades the given package)
uninstall (Uninstalls the given package)
hash     (Helper to hash installer files)
validate (Validates a manifest file)
settings (Open settings)
features (Shows the status of experimental features)
export   (Exports a list of the installed packages)
import   (Installs all the packages in a file)'
  local cur prev
  cur=${COMP_WORDS[COMP_CWORD]}
  [[ $COMP_CWORD -gt 1 ]] && prev=${COMP_WORDS[COMP_CWORD-1]}

  if [[ $COMP_CWORD = 1 ]]; then
    local OIFS="$IFS"
    local IFS=$'\n'
    COMPREPLY=( $(compgen -W '$tasks' -- "$cur") )
    if [[ ${#COMPREPLY[@]} -le 1 ]]; then
      COMPREPLY=( ${COMPREPLY[0]%% *} )
    fi
    IFS=$OIFS
    return
  fi

  local cmd="${COMP_WORDS[1]}"
  case "$cmd" in
    source)
      local OIFS="$IFS"
      local IFS=$'\n'
      local tasks='add    (Add a new source)
list   (List current sources)
update (Update current sources)
remove (Remove current sources)
reset  (Reset sources)
export (Export current sources)'
      COMPREPLY=( $(compgen -W '$tasks' -- "$cur") )
      IFS=$OIFS
      return
    ;;
  esac
}

complete -F _winget winget