#compdef artixpkg

local -a addcmd admincmd cicmd clonecmd configcmd createcmd gitcmd importcmd \
         initialcmd maintainercmd movecmd querycmd pullcmd pushcmd removecmd \
         repocmd showcmd teamcmd topiccmd transfercmd versioncmd
_regex_words maintainer '' \
                        '-a' \
                        '--adopt' \
                        '-h' \
                        '--help' \
                        '-o' \
                        '--orphan'
maintainercmd=("$reply[@]")

_regex_words query '' \
                   '-h' \
                   '--help' \
                   '-m' \
                   '-t'
querycmd=("$reply[@]")

_regex_words team '' \
                  '-a' \
                  '--add' \
                  '-c' \
                  '--check' \
                  '-h' \
                  '--help' \
                  '-r' \
                  '--remove'
teamcmd=("$reply[@]")

_regex_words topic '' \
                   '-a' \
                   '--add' \
                   '-d' \
                   '--delete' \
                   '-h' \
                   '--help' \
                   '-j' \
                   '--jobs' \
                   '-r' \
                   '--remove'
topiccmd=("$reply[@]")

_regex_words transfer '' \
                      '-h' \
                      '--help'
transfercmd=("$reply[@]")


_regex_words admin '' \
                   '-h:Help text' \
                   '--help:Help text' \
                   'maintainer:Manage repo maintainer:$maintainercmd' \
                   'query:Query maintainers and topics:$querycmd' \
                   'team:Manage repo team:$teamcmd' \
                   'topic:Manage topics:$topiccmd' \
                   'transfer:Transfer obsolete repositories to landfill:$transfercmd'
admincmd=("$reply[@]")

_regex_words ci '' \
                '-a' \
                '--agent' \
                '-h' \
                '--help'
cicmd=("$reply[@]")

_regex_words clone '' \
                   '-a' \
                   '--agent' \
                   '--all' \
                   '-h' \
                   '--help' \
                   '-j' \
                   '--jobs' \
                   '-m' \
                   '--maintainer' \
                   '--protocol' \
                   '-s' \
                   '--search' \
                   '-t' \
                   '--team'
clonecmd=("$reply[@]")

_regex_words config '' \
                    '-h' \
                    '--help' \
                    '-j' \
                    '--jobs' \
                    '--protocol'
configcmd=("$reply[@]")

_regex_words create '' \
                    '-a' \
                    '--agent' \
                    '-c' \
                    '--create' \
                    '-h' \
                    '--help' \
                    '-t' \
                    '--team'
createcmd=("$reply[@]")

_regex_words pull '' \
                  '--all' \
                  '-h' \
                  '--help' \
                  '-j' \
                  '--jobs' \
                  '-m' \
                  '--maintainer' \
                  '-t' \
                  '--topic'
pullcmd=("$reply[@]")

_regex_words push '' \
                  '-h' \
                  '--help' \
                  '-j' \
                  '--jobs' \
                  '-m' \
                  '--maintainer' \
                  '-t' \
                  '--topic'
pushcmd=("$reply[@]")

_regex_words git '' \
                 'ci:Configure CI agent:$cicmd' \
                 'clone:Clone a package:$clonecmd' \
                 'config:Configure a clone:$configcmd' \
                 'create:Create a new gitea package repository:$createcmd' \
                 '-h:Help text' \
                 '--help:Help text' \
                 'pull:Pull a package repository:$pullcmd' \
                 'push:Push a package repository:$pushcmd'
gitcmd=("$reply[@]")

_regex_words add '' \
                 '-h' \
                 '--help' \
                 '-n' \
                 '--nocheck' \
                 '-p' \
                 '--push' \
                 '-r' \
                 '--rebuild'
addcmd=("$reply[@]")

_regex_words import '' \
                    '--del' \
                    '-h' \
                    '--help' \
                    '--tag'
importcmd=("$reply[@]")

_regex_words move '' \
                  '-h' \
                  '--help' \
                  '-p' \
                  '--push'
movecmd=("$reply[@]")

_regex_words remove '' \
                    '-h' \
                    '--help' \
                    '-p' \
                    '--push'
removecmd=("$reply[@]")

_regex_words show '' \
                  '-b' \
                  '--base' \
                  '-h' \
                  '--help' \
                  '-p' \
                  '--pkgs'
showcmd=("$reply[@]")

_regex_words repo '' \
                  'add:Add pkgbase to repo:$addcmd' \
                  '-h:Help text' \
                  '--help:Help text' \
                  'import:Import latest tag from arch upstream:$importcmd' \
                  'move:Move pkgbase between repos:$movecmd' \
                  'remove:Remove pkgbase from repo:$removecmd' \
                  'show:Show pkgbase repo db:$showcmd'
repocmd=("$reply[@]")

_regex_words version '' \
                     '-h' \
                     '--help'
versioncmd=("$reply[@]")

_regex_words initial '' \
                     'admin:Manage topics:$admincmd' \
                     'git:Manage git:$gitcmd' \
                     '-h:Help text' \
                     '--help:Help text' \
                     'repo:Pacman database modification:$repocmd' \
                     'version:Show artixpkg version:$versioncmd'
initialcmd=("$reply[@]")

_regex_arguments _artixpkg /$'[^\0]##\0'/ "${initialcmd[@]}"
_artixpkg "$@"
