fedpkg(1) completion for zsh
Alexey I. Froloff
raorn at raorn.name
Wed Jun 6 12:05:40 UTC 2012
Hi,
Just sharing my fedpkg(1) completion for zsh :-) Put this file
somewhere in your $fpath as usual.
--
Regards, --
Sir Raorn. --- http://thousandsofhate.blogspot.com/
-------------- next part --------------
#compdef fedpkg
(( $+functions[_fedpkg_targets] )) ||
_fedpkg_targets()
{
local expl
_wanted koji-targets expl 'target' compadd \
${${(f)"$(_call_program koji-targets koji list-targets --quiet 2>/dev/null)"}%% *}
}
(( $+functions[_fedpkg_arches] )) ||
_fedpkg_arches()
{
local expl
local -a arches
arches=( /etc/mock/[^-]##-[^-]##-[^-]##.cfg )
_wanted mock-arches expl 'arch' compadd \
${(u)${arches#/etc/mock/[^-]##-[^-]##-}%.cfg}
}
(( $+functions[_fedpkg_packages] )) ||
_fedpkg_packages()
{
local expl
_wanted repo-packages expl 'package' compadd \
${${(fu)"$(repoquery -Cs -- "$words[CURRENT]*")"}%-[^-]##-[^-]##.src.rpm}
}
(( $+functions[_fedpkg_branches] )) ||
_fedpkg_branches()
{
local expl
local -a git_opts
local -a branches
(( ${words[(I)--path]} )) &&
git_opts=( --git-dir ${words[${words[(i)--path]}+1]} )
branches=(${${(f)"$(git $git_opts for-each-ref --format='%(refname)' refs/heads 2>/dev/null)"}#refs/heads/})
branches+=(${${(f)"$(git $git_opts for-each-ref --format='%(refname)' refs/remotes 2>/dev/null)"}##refs/remotes/*/})
_wanted branch-names expl 'branch-name' compadd \
${(u)branches}
}
(( $+functions[_fedpkg-help] )) ||
_fedpkg-help () {
_arguments -C \
'(-h --help)'{-h,--help}'[show help message and exit]'
}
(( $+functions[_fedpkg-build] )) ||
_fedpkg-build () {
_arguments -C \
'(-h --help)'{-h,--help}'[show help message and exit]' \
'--arches[build for specific arches]:*:arch:_fedpkg_arches' \
'--md5[use md5 checksums]' \
'--nowait[on'\''t wait on build]' \
'--target[define build target to build into]:target:_fedpkg_targets' \
'--background[run the build at a low priority]' \
'--skip-tag[do not attempt to tag package]' \
'--scratch[rerform a scratch build]' \
'--srpm[build from an srpm]::srpm:_files -g "*.src.rpm"'
}
(( $+functions[_fedpkg-chain-build] )) ||
_fedpkg-chain-build () {
_arguments -C \
'(-h --help)'{-h,--help}'[show help message and exit]' \
'--arches[build for specific arches]:*:arch:_fedpkg_arches' \
'--md5[use md5 checksums]' \
'--nowait[on'\''t wait on build]' \
'--target[define build target to build into]:target:_fedpkg_targets' \
'--background[run the build at a low priority]' \
'*:package:_fedpkg_packages'
}
(( $+functions[_fedpkg-clean] )) ||
_fedpkg-clean () {
_arguments -C \
'(-h --help)'{-h,--help}'[show help message and exit]' \
'(-n --dry-run)'{-n,--dry-run}'[perform a dry-run]' \
'-x[do not follow .gitignore rules]'
}
(( $+functions[_fedpkg-clog] )) ||
_fedpkg-clog () {
_arguments -C \
'(-h --help)'{-h,--help}'[show help message and exit]' \
'--raw[generate a more "raw" clog without twiddling the contents]'
}
(( $+functions[_fedpkg-clone] )) ||
_fedpkg-clone () {
_arguments -C \
'(-h --help)'{-h,--help}'[show help message and exit]' \
'(-B --branches)'{-B,--branches}'[do an old style checkout with subdirs for branches]' \
'(-b --branch)'{-b,--branch}'[check out a specific branch]:branch:_fedpkg_branches' \
'(-a --anonymous)'{-a,--anonymous}'[check out a module anonymously]' \
':package:_fedpkg_packages'
}
(( $+functions[_fedpkg-commit] )) ||
_fedpkg-commit () {
_arguments -C \
'(-h --help)'{-h,--help}'[show help message and exit]' \
'(-c --clog)'{-c,--clog}'[generate the commit message from the %changelog section]' \
'--raw[make the clog raw]' \
'(-t --tag)'{-t,--tag}'[create a tag for this commit]' \
'(-m --message)'{-m,--message}'[use the given commit message]:message' \
'(-F --file)'{-F,--file}'[take the commit message from the given file]:file:_files' \
'(-p --push)'{-p,--push}'[commit and push as one action]' \
'*:file:_files'
}
(( $+functions[_fedpkg-compile] )) ||
_fedpkg-compile () {
_arguments -C \
'(-h --help)'{-h,--help}'[show help message and exit]' \
'--builddir[define an alternate builddir]:builddir:_files -/' \
'--arch[prep for a specific arch]:arch:_fedpkg_arches' \
'--short-circuit[short-circuit compile]'
}
(( $+functions[_fedpkg-diff] )) ||
_fedpkg-diff () {
_arguments -C \
'(-h --help)'{-h,--help}'[show help message and exit]' \
'--cached[view staged changes]' \
'*:file:_files'
}
(( $+functions[_fedpkg-gimmespec] )) ||
_fedpkg-gimmespec () {
_arguments -C \
'(-h --help)'{-h,--help}'[show help message and exit]'
}
(( $+functions[_fedpkg-gitbuildhash] )) ||
_fedpkg-gitbuildhash () {
_arguments -C \
'(-h --help)'{-h,--help}'[show help message and exit]' \
':build'
}
(( $+functions[_fedpkg-giturl] )) ||
_fedpkg-giturl () {
_arguments -C \
'(-h --help)'{-h,--help}'[show help message and exit]'
}
(( $+functions[_fedpkg-import] )) ||
_fedpkg-import () {
_arguments -C \
'(-h --help)'{-h,--help}'[show help message and exit]' \
':srpm:_files -g "*.src.rpm"'
}
(( $+functions[_fedpkg-install] )) ||
_fedpkg-install () {
_arguments -C \
'(-h --help)'{-h,--help}'[show help message and exit]' \
'--builddir[define an alternate builddir]:builddir:_files -/' \
'--arch[prep for a specific arch]:arch:_fedpkg_arches' \
'--short-circuit[short-circuit compile]'
}
(( $+functions[_fedpkg-lint] )) ||
_fedpkg-lint () {
_arguments -C \
'(-h --help)'{-h,--help}'[show help message and exit]' \
'(-i --info)'{-i,--info}'[display explanations for reported messages]' \
'(-r --rpmlintconf)'{-r,--rpmlintconf}'[use a specific configuration file for rpmlint]:rpmlintconf:_files'
}
(( $+functions[_fedpkg-local] )) ||
_fedpkg-local () {
_arguments -C \
'(-h --help)'{-h,--help}'[show help message and exit]' \
'--builddir[define an alternate builddir]:builddir:_files -/' \
'--arch[prep for a specific arch]:arch:_fedpkg_arches' \
'--md5[use md5 checksums]'
}
(( $+functions[_fedpkg-mockbuild] )) ||
_fedpkg-mockbuild () {
_arguments -C \
'(-h --help)'{-h,--help}'[show help message and exit]' \
'--root[override mock root]:root:_files -/' \
'--md5[use md5 checksums]'
}
(( $+functions[_fedpkg-mock-config] )) ||
_fedpkg-mock-config () {
_arguments -C \
'(-h --help)'{-h,--help}'[show help message and exit]' \
'--target[override target used for config]:target:_fedpkg_targets'
'--arch[override local arch]:arch:_fedpkg_arches'
}
(( $+functions[_fedpkg-new] )) ||
_fedpkg-new () {
_arguments -C \
'(-h --help)'{-h,--help}'[show help message and exit]'
}
(( $+functions[_fedpkg-new-sources] )) ||
_fedpkg-new-sources () {
_arguments -C \
'(-h --help)'{-h,--help}'[show help message and exit]' \
'*:file:_files'
}
(( $+functions[_fedpkg-patch] )) ||
_fedpkg-patch () {
_arguments -C \
'(-h --help)'{-h,--help}'[show help message and exit]' \
'--rediff[recreate gendiff file retaining comments]' \
':suffix'
}
(( $+functions[_fedpkg-prep] )) ||
_fedpkg-prep () {
_arguments -C \
'(-h --help)'{-h,--help}'[show help message and exit]' \
'--builddir[define an alternate builddir]:builddir:_files -/' \
'--arch[prep for a specific arch]:arch:_fedpkg_arches'
}
(( $+functions[_fedpkg-pull] )) ||
_fedpkg-pull () {
_arguments -C \
'(-h --help)'{-h,--help}'[show help message and exit]' \
'(--no-rebase)--rebase[rebase the locally committed changes on top of the remote changes]' \
'(--rebase)--no-rebase[do not rebase, override .git settings to automatically rebase]'
}
(( $+functions[_fedpkg-push] )) ||
_fedpkg-push () {
_arguments -C \
'(-h --help)'{-h,--help}'[show help message and exit]'
}
(( $+functions[_fedpkg-scratch-build] )) ||
_fedpkg-scratch-build () {
_arguments -C \
'(-h --help)'{-h,--help}'[show help message and exit]' \
'--arches[build for specific arches]:*:arch:_fedpkg_arches' \
'--md5[use md5 checksums]' \
'--nowait[on'\''t wait on build]' \
'--target[define build target to build into]:target:_fedpkg_targets' \
'--background[run the build at a low priority]' \
'--srpm[build from an srpm]::srpm:_files -g "*.src.rpm"'
}
(( $+functions[_fedpkg-sources] )) ||
_fedpkg-sources () {
_arguments -C \
'(-h --help)'{-h,--help}'[show help message and exit]' \
'--outdir[directory to download files into]:outdir:_files -/'
}
(( $+functions[_fedpkg-srpm] )) ||
_fedpkg-srpm () {
_arguments -C \
'(-h --help)'{-h,--help}'[show help message and exit]' \
'--md5[use md5 checksums]'
}
(( $+functions[_fedpkg-switch-branch] )) ||
_fedpkg-switch-branch () {
_arguments -C \
'(-h --help)'{-h,--help}'[show help message and exit]' \
'(: -l --list)'{-l,--list}'[list both remote-tracking branches and local branches]' \
'(-):branch:_fedpkg_branches'
}
(( $+functions[_fedpkg-tag] )) ||
_fedpkg-tag () {
_arguments -C \
'(-h --help)'{-h,--help}'[show help message and exit]' \
'(-f --force)'{-f,--force}'[force the creation of the tag]' \
'(-m --message)'{-m,--message}'[use the given commit message]:message' \
'(-c --clog)'{-c,--clog}'[generate the commit message from the %changelog section]' \
'--raw[make the clog raw]' \
'(-F --file)'{-F,--file}'[take the commit message from the given file]:file:_files' \
'(-l --list)'{-l,--list}'[list all tags with a given pattern]' \
'(-d --delete)'{-d,--delete}'[delete a tag]' \
':tag'
}
(( $+functions[_fedpkg-unused-patches] )) ||
_fedpkg-unused-patches () {
_arguments -C \
'(-h --help)'{-h,--help}'[show help message and exit]'
}
(( $+functions[_fedpkg-upload] )) ||
_fedpkg-upload () {
_arguments -C \
'(-h --help)'{-h,--help}'[show help message and exit]' \
'*:file:_files'
}
(( $+functions[_fedpkg-verify-files] )) ||
_fedpkg-verify-files () {
_arguments -C \
'(-h --help)'{-h,--help}'[show help message and exit]' \
'--builddir[define an alternate builddir]:builddir:_files -/' \
'--arch[prep for a specific arch]:arch:_fedpkg_arches'
}
(( $+functions[_fedpkg-verrel] )) ||
_fedpkg-verrel () {
_arguments -C \
'(-h --help)'{-h,--help}'[show help message and exit]'
}
(( $+functions[_fedpkg-retire] )) ||
_fedpkg-retire () {
_arguments -C \
'(-h --help)'{-h,--help}'[show help message and exit]' \
'(-p --push)'{-p,--push}'[push changes to remote repository]' \
':message'
}
(( $+functions[_fedpkg-tag-request] )) ||
_fedpkg-tag-request () {
_arguments -C \
'(-h --help)'{-h,--help}'[show help message and exit]' \
'--desc[description of tag request]:description' \
'--build[override the build n-v-r]:build'
}
(( $+functions[_fedpkg-update] )) ||
_fedpkg-update () {
_arguments -C \
'(-h --help)'{-h,--help}'[show help message and exit]'
}
(( $+functions[_fedpkg_commands] )) ||
_fedpkg_commands () {
local -a fedpkg_commands
fedpkg_commands=(
help:'show usage'
build:'request build'
chain-build:'build current package in order with other packages'
clean:'remove untracked files'
clog:'make a clog file containing top changelog entry'
clone:'clone and checkout a module'
commit:'commit changes'
compile:'local test rpmbuild compile'
diff:'show changes between commits, commit and working tree, etc'
gimmespec:'print the spec file name'
gitbuildhash:'print the git hash used to build the provided n-v-r'
giturl:'print the git url for building'
import:'import srpm content into a module'
install:'local test rpmbuild install'
lint:'run rpmlint against local spec and build output if present'
local:'local test rpmbuild binary'
mockbuild:'local test build using mock'
mock-config:'generate a mock config'
new:'diff against last tag'
new-sources:'upload new source files'
patch:'create and add a gendiff patch file'
prep:'local test rpmbuild prep'
pull:'pull changes from remote repository and update working copy'
push:'push changes to remote repository'
scratch-build:'request scratch build'
sources:'download source files'
srpm:'create a source rpm'
switch-branch:'work with branches'
tag:'management of git tags'
unused-patches:'print list of patches not referenced by name in the specfile'
upload:'upload source files'
verify-files:'locally verify %files section'
verrel:'print the name-version-release'
retire:'retire a package'
tag-request:'submit current build nvr as a releng tag request'
update:'submit last build as an update'
)
integer ret=1
# TODO: Is this the correct way of doing it? Should we be using _alternative
# and separate functions for each set of commands instead?
_describe -t fedpkg-commands 'fedpkg command' fedpkg_commands && ret=0
return ret
}
_fedpkg() {
local -A fedpkg_aliases
fedpkg_aliases=(
co clone
ci commit
)
integer ret=1
local curcontext=$curcontext state line
declare -A opt_args
_arguments -C \
'(- :)'{-h,--help}'[show help message and exit]' \
'(-C --config)'{-C,--config}'[specify a config file to use]:config file:_files' \
'--dist[override the discovered distribution]:distribution' \
'--user[override the discovered user name]:user' \
'--path[define the directory to work in (defaults to cwd)]:working direcory:_directories' \
'(-q)-v[run with verbose debug output]' \
'(-v)-q[run quietly only displaying errors]' \
'(-): :->command' \
'(-)*:: :->option-or-argument' && return
case $state in
(command)
_fedpkg_commands && ret=0
;;
(option-or-argument)
local cmd=$words[1]
(( $+fedpkg_aliases[$cmd] )) &&
cmd=$fedpkg_aliases[$cmd]
curcontext=${curcontext%:*:*}:fedpkg-$cmd:
if (( $+functions[_fedpkg-$cmd] )); then
_call_function ret _fedpkg-$cmd
elif zstyle -T :completion:$curcontext: use-fallback; then
_files && ret=0
else
_message 'unknown sub-command'
fi
;;
esac
return ret
}
_fedpkg
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 490 bytes
Desc: Digital signature
URL: <http://lists.fedoraproject.org/pipermail/devel/attachments/20120606/f9f89311/attachment.sig>
More information about the devel
mailing list