_timber_filter() {
local cur prev
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD - 1]}"
local flags="--has --has-caseless --substring --substring-caseless \
--regex --any --any-caseless --not-has --not-has-caseless --not-substring \
--not-substring-caseless --not-regex --from --to -c --count --max -0 --null \
--no-filename --records --quiet --timestamp-regex --timestamp-format \
-h --help -V --version"
case "$prev" in
--has | --has-caseless | --substring | --substring-caseless | --regex | \
--any | --any-caseless | --not-has | --not-has-caseless | \
--not-substring | --not-substring-caseless | --not-regex | \
--from | --to | --max | --timestamp-regex | --timestamp-format)
COMPREPLY=($(compgen -f -- "$cur"))
return 0
;;
esac
case "$cur" in
-*)
COMPREPLY=($(compgen -W "$flags" -- "$cur"))
return 0
;;
esac
local handles
handles=$(timberfs list --names 2>/dev/null)
COMPREPLY=($(compgen -W "$handles" -- "$cur") $(compgen -f -- "$cur"))
return 0
}
complete -F _timber_filter timber-filter