#compdef sbohints

# sbotools: https://pghvlaans.github.io/sbotools/

# work out where the SBo repo is (default to /usr/sbo/repo)
# but also check for SBO_HOME setting in /etc/sbotools/sbotools.conf
grep 'SBO_HOME' /etc/sbotools/sbotools.conf &> /dev/null
if [ $? -eq 0 ]; then
    repo="$(grep 'SBO_HOME' /etc/sbotools/sbotools.conf | cut -d= -f2)/repo"
else
    repo='/usr/sbo/repo'
fi

# grab a listing of all slackbuilds
slackbuilds=( ${(uf)"$(grep 'SLACKBUILD NAME: ' $repo/SLACKBUILDS.TXT | cut -b 18-)"} )

_arguments -s \
	   - info \
	   '(-)'{-h,--help}'[Show help]:' \
	   '(-)'{-v,--version}'[Show version information.]:' \
	   '(-)'{--nocolor}'[Disable sbotools color output.]:' \
	   '(-)'{--color}'[Enable sbotools color output.]:' \
	   '(-)'{--nowrap}'[Disable sbotools word wrapping.]:' \
	   '(-)'{--wrap}'[Enable sbotools word wrapping.]:' \
	   - commands \
	   '(-q --query)'{-q,--query}'[Get the hint status of one or more scripts.]:' \
	   '(-l --list)'{-l,--list}'[Display all hints.]:' \
	   '(-b --blacklist)'{-b,--blacklist}'[Add (or clear with -c) scripts to the blacklist.]:' \
	   '(-o --optional)'{-o,--optional}'[Add (or clear with -c) optional dependency requests for one or more scripts.]:' \
	   '(-r --reverse)'{-r,--reverse}'[Add (or clear with -c) reverse dependency rebuild requests for one or more scripts.]:' \
	   '(-O --replace-optional)'{-O,--replace-optional}'[Replace (or remove with -r) all optional dependency requests for one or more scripts.]:' \
	   '(-c --clear)'{-c,--clear}'[Together with -b, -r, -o or -O, clear items instead of adding or replacing.]:'\
	   '(-)*:SlackBuild:(${slackbuilds:|words})' \
    && return 0

return 1

# Local Variables:
# mode: sh
# End:
