## [@bashly-upgrade completions send_completions]
send_completions() {
  echo $'# cli completion                                           -*- shell-script -*-'
  echo $''
  echo $'# This bash completions script was generated by'
  echo $'# completely (https://github.com/bashly-framework/completely)'
  echo $'# Modifying it manually is not recommended'
  echo $''
  echo $'_cli_completions_filter() {'
  echo $'  local words="$1"'
  echo $'  local cur=${COMP_WORDS[COMP_CWORD]}'
  echo $'  local result=()'
  echo $''
  echo $'  # words the user already typed (excluding the command itself)'
  echo $'  local used=()'
  echo $'  if ((COMP_CWORD > 1)); then'
  echo $'    used=("${COMP_WORDS[@]:1:$((COMP_CWORD - 1))}")'
  echo $'  fi'
  echo $''
  echo $'  if [[ "${cur:0:1}" == "-" ]]; then'
  echo $'    # Completing an option: offer everything (including options)'
  echo $'    echo "$words"'
  echo $''
  echo $'  else'
  echo $'    # Completing a non-option: offer only non-options,'
  echo $'    # and don\'t re-offer ones already used earlier in the line.'
  echo $'    for word in $words; do'
  echo $'      [[ "${word:0:1}" == "-" ]] && continue'
  echo $''
  echo $'      local seen=0'
  echo $'      for u in "${used[@]}"; do'
  echo $'        if [[ "$u" == "$word" ]]; then'
  echo $'          seen=1'
  echo $'          break'
  echo $'        fi'
  echo $'      done'
  echo $'      ((!seen)) && result+=("$word")'
  echo $'    done'
  echo $''
  echo $'    echo "${result[*]}"'
  echo $'  fi'
  echo $'}'
  echo $''
  echo $'_cli_completions() {'
  echo $'  local cur=${COMP_WORDS[COMP_CWORD]}'
  echo $'  local compwords=()'
  echo $'  if ((COMP_CWORD > 0)); then'
  echo $'    compwords=("${COMP_WORDS[@]:1:$((COMP_CWORD - 1))}")'
  echo $'  fi'
  echo $'  local compline="${compwords[*]}"'
  echo $''
  echo $'  COMPREPLY=()'
  echo $''
  echo $'  case "$compline" in'
  echo $'    \'download\'*\'--handler\')'
  echo $'      while read -r; do COMPREPLY+=("$REPLY"); done < <(compgen -W "$(_cli_completions_filter "curl wget")" -- "$cur")'
  echo $'      ;;'
  echo $''
  echo $'    \'upload\'*\'--user\')'
  echo $'      while read -r; do COMPREPLY+=("$REPLY"); done < <(compgen -A user -- "$cur")'
  echo $'      ;;'
  echo $''
  echo $'    \'completions\'*)'
  echo $'      while read -r; do COMPREPLY+=("$REPLY"); done < <(compgen -W "$(_cli_completions_filter "--help -h")" -- "$cur")'
  echo $'      ;;'
  echo $''
  echo $'    \'d\'*\'--handler\')'
  echo $'      while read -r; do COMPREPLY+=("$REPLY"); done < <(compgen -W "$(_cli_completions_filter "curl wget")" -- "$cur")'
  echo $'      ;;'
  echo $''
  echo $'    \'upload\'*\'-u\')'
  echo $'      while read -r; do COMPREPLY+=("$REPLY"); done < <(compgen -A user -- "$cur")'
  echo $'      ;;'
  echo $''
  echo $'    \'download\'*)'
  echo $'      while read -r; do COMPREPLY+=("$REPLY"); done < <(compgen -A file -W "$(_cli_completions_filter "--force --handler --help -f -h")" -- "$cur")'
  echo $'      ;;'
  echo $''
  echo $'    \'u\'*\'--user\')'
  echo $'      while read -r; do COMPREPLY+=("$REPLY"); done < <(compgen -A user -- "$cur")'
  echo $'      ;;'
  echo $''
  echo $'    \'upload\'*)'
  echo $'      while read -r; do COMPREPLY+=("$REPLY"); done < <(compgen -A directory -A user -W "$(_cli_completions_filter "--help --password --user -h -p -u CHANGELOG.md README.md")" -- "$cur")'
  echo $'      ;;'
  echo $''
  echo $'    \'u\'*\'-u\')'
  echo $'      while read -r; do COMPREPLY+=("$REPLY"); done < <(compgen -A user -- "$cur")'
  echo $'      ;;'
  echo $''
  echo $'    \'d\'*)'
  echo $'      while read -r; do COMPREPLY+=("$REPLY"); done < <(compgen -A file -W "$(_cli_completions_filter "--force --handler --help -f -h")" -- "$cur")'
  echo $'      ;;'
  echo $''
  echo $'    \'u\'*)'
  echo $'      while read -r; do COMPREPLY+=("$REPLY"); done < <(compgen -A directory -A user -W "$(_cli_completions_filter "--help --password --user -h -p -u CHANGELOG.md README.md")" -- "$cur")'
  echo $'      ;;'
  echo $''
  echo $'    *)'
  echo $'      while read -r; do COMPREPLY+=("$REPLY"); done < <(compgen -W "$(_cli_completions_filter "--help --version -h -v completions d download u upload")" -- "$cur")'
  echo $'      ;;'
  echo $''
  echo $'  esac'
  echo $'} &&'
  echo $'  complete -F _cli_completions cli'
  echo $''
  echo $'# ex: filetype=sh'
}