.bash_completion.d/winget
changeset 1001 b4df956c3d52
equal deleted inserted replaced
1000:e3e1539cafa9 1001:b4df956c3d52
       
     1 # -*- mode: sh; sh-shell-file: bash -*-
       
     2 
       
     3 
       
     4 _winget() {
       
     5   local tasks='install  (Installs the given package)
       
     6 show     (Shows information about a package)
       
     7 source   (Manage sources of packages)
       
     8 search   (Find and show basic info of packages)
       
     9 list     (Display installed packages)
       
    10 upgrade  (Upgrades the given package)
       
    11 uninstall (Uninstalls the given package)
       
    12 hash     (Helper to hash installer files)
       
    13 validate (Validates a manifest file)
       
    14 settings (Open settings)
       
    15 features (Shows the status of experimental features)
       
    16 export   (Exports a list of the installed packages)
       
    17 import   (Installs all the packages in a file)'
       
    18   local cur prev
       
    19   cur=${COMP_WORDS[COMP_CWORD]}
       
    20   [[ $COMP_CWORD -gt 1 ]] && prev=${COMP_WORDS[COMP_CWORD-1]}
       
    21 
       
    22   if [[ $COMP_CWORD = 1 ]]; then
       
    23     local OIFS="$IFS"
       
    24     local IFS=$'\n'
       
    25     COMPREPLY=( $(compgen -W '$tasks' -- "$cur") )
       
    26     if [[ ${#COMPREPLY[@]} -le 1 ]]; then
       
    27       COMPREPLY=( ${COMPREPLY[0]%% *} )
       
    28     fi
       
    29     IFS=$OIFS
       
    30     return
       
    31   fi
       
    32 
       
    33   local cmd="${COMP_WORDS[1]}"
       
    34   case "$cmd" in
       
    35     source)
       
    36       local OIFS="$IFS"
       
    37       local IFS=$'\n'
       
    38       local tasks='add    (Add a new source)
       
    39 list   (List current sources)
       
    40 update (Update current sources)
       
    41 remove (Remove current sources)
       
    42 reset  (Reset sources)
       
    43 export (Export current sources)'
       
    44       COMPREPLY=( $(compgen -W '$tasks' -- "$cur") )
       
    45       IFS=$OIFS
       
    46       return
       
    47     ;;
       
    48   esac
       
    49 }
       
    50 
       
    51 complete -F _winget winget