#  Copyright (C) 2003 Ingo K"ohne
#  
#  This program is free software; you can redistribute it and/or
#  modify it under the terms of the GNU General Public License
#  as published by the Free Software Foundation; either version 2
#  of the License, or (at your option) any later version.
#  
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#  
#  You should have received a copy of the GNU General Public License along
#  with this program; if not, write to the Free Software Foundation, Inc.,
#  59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.

. ../include/common

cmd=tar

# commands
optcomplete -V cmd -T '-z "$XPC_cmd"'  $cmd concatenate catenate A
optcomplete -V cmd -T '-z "$XPC_cmd"'  $cmd create c
optcomplete -V cmd -T '-z "$XPC_cmd"'  $cmd diff compare d
optcomplete -V cmd -T '-z "$XPC_cmd"'  $cmd delete
optcomplete -V cmd -T '-z "$XPC_cmd"'  $cmd append r
optcomplete -V cmd -T '-z "$XPC_cmd"'  $cmd list t
optcomplete -V cmd -T '-z "$XPC_cmd"'  $cmd u update
optcomplete -V cmd -T '-z "$XPC_cmd"'  $cmd extract x get              

optcomplete -V opt -T '-n "$XPC_cmd"'  $cmd atime-preserve
optcomplete -V opt -T '-n "$XPC_cmd"' -m arg_required  $cmd b block-size
optcomplete -V opt -T '-n "$XPC_cmd"'  $cmd read-full-blocks B
optcomplete -V opt -T '-n "$XPC_cmd"' -d  $cmd C directory
optcomplete -V opt -T '-n "$XPC_cmd"'  $cmd checkpoint
optcomplete -V opt -T '-n "$XPC_cmd"' -f  $cmd f file
optcomplete -V opt -T '-n "$XPC_cmd"'  $cmd force-local
optcomplete -V opt -T '-n "$XPC_cmd"' -f  $cmd F info-script
optcomplete -V opt -T '-n "$XPC_cmd"'  $cmd G incremental
optcomplete -V opt -T '-n "$XPC_cmd"' -f  $cmd g listed-incremental
optcomplete -V opt -T '-n "$XPC_cmd"'  $cmd h dereference
optcomplete -V opt -T '-n "$XPC_cmd"'  $cmd ignore-zeros i
optcomplete -V opt -T '-n "$XPC_cmd"'  $cmd j bzip2
optcomplete -V opt -T '-n "$XPC_cmd"'  $cmd ignore-failed-read
optcomplete -V opt -T '-n "$XPC_cmd"'  $cmd k keep-old-files
optcomplete -V opt -T '-n "$XPC_cmd"' -f  $cmd starting-file K
optcomplete -V opt -T '-n "$XPC_cmd"'  $cmd one-file-system l
optcomplete -V opt -T '-n "$XPC_cmd"' -m arg_required  $cmd tape-length L
optcomplete -V opt -T '-n "$XPC_cmd"'  $cmd m modification-time
optcomplete -V opt -T '-n "$XPC_cmd"'  $cmd multi-volume M
optcomplete -V opt -T '-n "$XPC_cmd"' -m arg_required  $cmd N newer after-date
optcomplete -V opt -T '-n "$XPC_cmd"'  $cmd portability old-archive o
optcomplete -V opt -T '-n "$XPC_cmd"'  $cmd O to-stdout
optcomplete -V opt -T '-n "$XPC_cmd"'  $cmd preserve-permissions same-permissions p
optcomplete -V opt -T '-n "$XPC_cmd"'  $cmd P absolute-paths
optcomplete -V opt -T '-n "$XPC_cmd"'  $cmd preserve
optcomplete -V opt -T '-n "$XPC_cmd"'  $cmd R record-number
optcomplete -V opt -T '-n "$XPC_cmd"'  $cmd remove-files
optcomplete -V opt -T '-n "$XPC_cmd"'  $cmd same-order preserve-order s
optcomplete -V opt -T '-n "$XPC_cmd"'  $cmd same-owner
optcomplete -V opt -T '-n "$XPC_cmd"'  $cmd numeric-owner
optcomplete -V opt -T '-n "$XPC_cmd"'  $cmd sparse S
optcomplete -V opt -T '-n "$XPC_cmd"' -f  $cmd files-from T
optcomplete -V opt -T '-n "$XPC_cmd"'  $cmd null
optcomplete -V opt -T '-n "$XPC_cmd"'  $cmd totals
optcomplete -V opt -T '-n "$XPC_cmd"'  $cmd verbose v
optcomplete -V opt -T '-n "$XPC_cmd"' -m arg_required  $cmd V label
optcomplete -V opt -T '-n "$XPC_cmd"'  $cmd version
optcomplete -V opt -T '-n "$XPC_cmd"'  $cmd w confirmation interactive
optcomplete -V opt -T '-n "$XPC_cmd"'  $cmd verify W
optcomplete -V opt -T '-n "$XPC_cmd"' -f  $cmd exclude
optcomplete -V opt -T '-n "$XPC_cmd"' -f  $cmd exclude-from X
optcomplete -V opt -T '-n "$XPC_cmd"'  $cmd uncompress compress Z
optcomplete -V opt -T '-n "$XPC_cmd"'  $cmd gzip ungzip z
optcomplete -V opt -T '-n "$XPC_cmd"' -c  $cmd use-compress-program
optcomplete -V opt -T '-n "$XPC_cmd"'  $cmd block-compress
# completing the non-dash (plain 'xzf') option argument is really incomplete
optcomplete -V nonopt -m array,rlhint -C '
if test -n "$XPC_cmd"; then
	echo -e "\efilename"
	compgen -f -- "$XPC_PATTERN"
	return
fi
if test $XPC_NONOPT_NO = 1; then
	cat <<EOF
--concatenate
--catenate
-A
--create
-c
--diff
--compare
-d
--delete
--append
-r
--list
-t
-u
--update
--extract
-x
--get
EOF
fi
case "${XPC_nonopt[0]}" in
*[tx]*f|*c*)
	echo -e "\efilename"
	compgen -f -- "$XPC_PATTERN"
	;;
esac
#' $cmd NONOPT

optcomplete -m long,getoptparse  $cmd

complete -F xpcompfunc  $cmd

unset cmd ${!xpc_*}
