#autoload

# Pass -a attribute to filter types, e.g.:
#   -a domain    - for process types
#   -a file_type - for file types
#   -a port_type - for network ports

local -a setypes expl extra

zparseopts -E -D -a extra a:

if (( $#extra )); then
  setypes=( ${${${(f)"$(_call_program selinux-types seinfo $extra --flat -x)"}#[[:blank:]]}:1} )
else
  setypes=( ${(f)"$(_call_program selinux-types seinfo --flat -t)"} )
fi

_description selinux-types expl "selinux type"
compadd "$@" "$expl[@]" -a setypes
