# bts completion -*- shell-script -*- # List bug numbers from bugs cache in ~/.devscripts_cache/bts proc _cached_bugs { [[ -d $HOME/.devscripts_cache/bts ]] && \ find $HOME/.devscripts_cache/bts -maxdepth 1 -name "$cur[0-9]*.html" -printf "%f\n" | cut -d'.' -f1 } # List APT source packages prefixed with "src:" proc _src_packages_with_prefix { setglobal ppn = $(cur:4) # partial package name, after stripping "src:" compgen -P "src:" -W '$( _xfunc apt-cache _apt_cache_sources "$ppn" )' -- $ppn } proc _bts { local cur prev words cword split _init_completion -s || return match $prev { with show|bugs setglobal COMPREPLY = ''( $( compgen -W 'release-critical RC from: tag: usertag:' -- "$cur" ) $( _cached_bugs ) $( _src_packages_with_prefix ) ) return 0 with select setglobal COMPREPLY = ''( $( compgen -W 'package: source: maintainer: submitter: severity: status: tag: owner: correspondent: affects: bugs: users: archive:' -- "$cur" ) ) return 0 with status setglobal COMPREPLY = ''( $( compgen -W 'file: fields: verbose' -- "$cur" ) $( _cached_bugs ) ) return 0 with block|unblock setglobal COMPREPLY = ''( $( compgen -W 'by with' -- "$cur" ) ) return 0 with severity setglobal COMPREPLY = ''( $( compgen -W 'wishlist minor normal important serious grave critical' -- "$cur" ) ) return 0 with limit setglobal COMPREPLY = ''( $( compgen -W 'submitter date subject msgid package source tag severity owner affects archive' -- "$cur" ) ) return 0 with clone|done|reopen|archive|unarchive|retitle|summary|submitter|found\ |notfound|fixed|notfixed|merge|forcemerge|unmerge|claim|unclaim\ |forwarded|notforwarded|owner|noowner|subscribe|unsubscribe\ |reportspam|spamreport|affects|usertag|usertags|reassign|tag\ |tags setglobal COMPREPLY = ''( $( _cached_bugs ) ) return 0 with package setglobal COMPREPLY = ''( $( _xfunc apt-cache _apt_cache_packages ) ) return 0 with cache setglobal COMPREPLY = ''( $( _xfunc apt-cache _apt_cache_packages ) $( _src_packages_with_prefix ) $( compgen -W 'from: release-critical RC' -- "$cur" )) return 0 with cleancache setglobal COMPREPLY = ''( $( _xfunc apt-cache _apt_cache_packages ) $( _src_packages_with_prefix ) $( compgen -W 'from: tag: usertag: ALL' -- "$cur" )) return 0 with user # non-predicible arguments setglobal COMPREPLY = ''( ) return 0 with : # Chances are that "src:" is being completed # COMP_WORDS would be: "bts cleancache src : " setglobal pos = $shExpr('COMP_CWORD - 2') if [[ $pos -gt 0 && "${COMP_WORDS[$pos]}" == "src" ]] { setglobal COMPREPLY = ''( $( _xfunc apt-cache _apt_cache_src_packages ) ) return 0 } } $split && return 0 setglobal COMPREPLY = ''( $( compgen -W '--offline --online --no-offline --no-action --cache --no-cache --cache-mode --cache-delay --mbox --mailreader --cc-addr --use-default-cc --no-use-default-cc --sendmail --mutt --no-mutt --smtp-host --smtp-username --smtp-helo --bts-server --force-refresh --no-force-refresh --only-new --include-resolved --no-include-resolved --no-ack --ack --interactive --force-interactive --no-interactive --quiet --no-conf --noconf show bugs select status clone done reopen archive unarchive retitle summary submitter reassign found notfound fixed notfixed block unblock merge forcemerge unmerge tag tags affects user usertag usertags claim unclaim severity forwarded notforwarded package limit owner noowner subscribe unsubscribe reportspam spamreport cache cleancache version help' -- "$cur" ) ) return 0 } && complete -F _bts bts # ex: ts=4 sw=4 et filetype=sh