#compdef sboupgrade

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

# get a list of available upgrades
sboupdates=( ${(uf)"$(perl -MSBO::Lib::Pkgs=get_available_updates -E 'say $_->{name} for @{ get_available_updates("BOTH"); }')"} )

_arguments -s -C \
	   - 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 \
	   '(${sboupdates})--all[Upgrade all from sbocheck.]' \
	   '(-b --build-ignore)'{-b,--build-ignore}'[If TRUE, then only do upgrades if the version number differs.]:ignore build number?:((TRUE\:"Version upgrades only" FALSE\:"Script bump upgrades"))' \
	   '(-c --noclean)'{-c,--noclean}'[If TRUE, then do not clean working directories after build.]:clean work dirs?:((TRUE\:"Clean works directories" FALSE\:"Keep work directories"))' \
	   '(-d --distclean)'{-d,--distclean}'[If TRUE, then remove source code and the package after building.]:clean source and package?:((TRUE\:"Remove source and package" FALSE\:"Keep source and package"))' \
	   '(-e --etc-profile)'{-e,--etc-profile}'[If TRUE, then source executable *.sh scripts in /etc/profile.d before building.]:source /etc/profile.d before building?:((TRUE\:"Source /etc/profile.d before building" FALSE\:"Do not source /etc/profile.d before building"))' \
	   '(-j --jobs)'{-j,--jobs}'[Number fed to -j# for make.]:number of jobs (make):()' \
	   '(-k --pkg-dir)'{-k,--pkg-dir}'[If an absolute path, save built packages here. If FALSE, do not save packages to PKG_DIR.]override default PKG_DIR?:((path\: "Save built packages here" FALSE\:"Do not save packages to PKG_DIR"))'\
	   '(-L --log-dir)'{-L,--log-dir}'[If an absolute path, save build logs here. If FALSE, do not save logs.]override default LOG_DIR?:((path\: "Save build logs here" FALSE\:"Do not save logs to LOG_DIR"))'\
	   '(-o --norecall)'{-o,--norecall}'[Do not automatically reuse build options if nointeractive.]' \
	   '(-q --reverse-rebuild)'{-q,--reverse-rebuild}'[Rebuild the reverse dependency queue after upgrading.]' \
	   '(-r --nointeractive)'{-r,--nointeractive}'[Skip README.]' \
	   '(-f --force)'{-f,--force}'[Force an upgrade (ignore version).]' \
	   '(-z --force-reqs)'{-z,--force-reqs}'[Force update of requirements.]' \
	   '(-i --noinstall)'{-i,--noinstall}'[Build package but do not install.]' \
	   '(-S --strict-upgrades)'{-S,--strict-upgrades}'[If TRUE, then only perform non-override upgrades if the version or build number is greater.]:strict versions?:((TRUE\:"Strict upgrades only." FALSE\:"Upgrade on differing version and build number."))' \
	   '(-X --so-check)'{-X,--so-check}'[If TRUE, then check for missing shared object dependencies after building.]:solib check?:((TRUE\:"Check for shared objects." FALSE\:"No shared object check."))' \
	   '--batch[Be non-interactive and calculate dependencies; use with caution.]' \
	   '(-D --dry-run)'{-D,--dry-run}'[Print the potential queue and exit.]' \
	   '(-)*:SlackBuild:(${sboupdates:|words})' \
    && return 0

return 1

# Local Variables:
# mode: sh
# End:
