_atp_completion() {
local cur prev opts
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
local commands="send get sync mirror share watch serve inbox resume cancel status doctor config pair unpair daemon version help"
local global_opts="--help --version --config --json --verbose --quiet"
case ${COMP_CWORD} in
1)
COMPREPLY=( $(compgen -W "${commands}" -- ${cur}) )
return 0
;;
*)
case ${prev} in
send)
COMPREPLY=( $(compgen -f -- ${cur}) )
return 0
;;
get)
local get_opts="--output --verify --resume"
COMPREPLY=( $(compgen -W "${get_opts}" -- ${cur}) )
return 0
;;
sync)
COMPREPLY=( $(compgen -d -- ${cur}) )
return 0
;;
mirror)
COMPREPLY=( $(compgen -d -- ${cur}) )
return 0
;;
share)
COMPREPLY=( $(compgen -f -- ${cur}) )
return 0
;;
watch)
COMPREPLY=( $(compgen -d -- ${cur}) )
return 0
;;
serve)
local serve_opts="--port --bind --public --readonly"
COMPREPLY=( $(compgen -W "${serve_opts}" -- ${cur}) )
return 0
;;
inbox)
local inbox_opts="list accept reject quarantine purge"
COMPREPLY=( $(compgen -W "${inbox_opts}" -- ${cur}) )
return 0
;;
status)
local status_opts="--transfers --peers --daemon --all"
COMPREPLY=( $(compgen -W "${status_opts}" -- ${cur}) )
return 0
;;
doctor)
local doctor_opts="--platform --network --permissions --fix"
COMPREPLY=( $(compgen -W "${doctor_opts}" -- ${cur}) )
return 0
;;
config)
local config_opts="show set get reset export import"
COMPREPLY=( $(compgen -W "${config_opts}" -- ${cur}) )
return 0
;;
pair)
local pair_opts="--code --qr --invite"
COMPREPLY=( $(compgen -W "${pair_opts}" -- ${cur}) )
return 0
;;
daemon)
local daemon_opts="start stop restart status logs"
COMPREPLY=( $(compgen -W "${daemon_opts}" -- ${cur}) )
return 0
;;
--config)
COMPREPLY=( $(compgen -f -X '!*.toml' -- ${cur}) )
return 0
;;
--output|-o)
COMPREPLY=( $(compgen -d -- ${cur}) )
return 0
;;
*)
COMPREPLY=( $(compgen -W "${global_opts}" -- ${cur}) )
return 0
;;
esac
;;
esac
}
complete -F _atp_completion atp