[devel] git.alt - new zsh completion
Alexey I. Froloff
raorn на altlinux.org
Вс Май 17 01:37:38 MSD 2009
Я переписал комплишн для git.alt. Теперь оно комплитит удалённые
пути для clone/rm-db/mv-db, номера тасков, а если мой патчик к
girar будет приложен, то и номера субтасков.
P.S. build srpm поддерживается.
--
Regards,
Sir Raorn.
-------------- next part --------------
#compdef git.alt
_git_alt_directories()
{
local expl
local -a remfiles
if compset -P '?*/'; then
remfiles=(${${${${${${${(M)${${(f)"$(_call_program package-repository git.alt ls ${words[CURRENT]%/*})"}:#total *}:#d*}##[^ ]## ##}##[^ ]## ##}##[^ ]## ##}##[^ ]## ##}##[^ ]## ##}##[^ ]## ##})
elif compset -P /; then
remfiles=(people archive gears)
else
remfiles=(${${${${${${${(M)${${(f)"$(_call_program package-repository git.alt ls)"}:#total *}:#d*}##[^ ]## ##}##[^ ]## ##}##[^ ]## ##}##[^ ]## ##}##[^ ]## ##}##[^ ]## ##})
fi
_wanted files expl 'git.alt directories' \
compadd -S/ -q -- $remfiles
}
_git_alt_tasks()
{
local -a tasks
tasks=(${${${${(f)"$(_call_program task-id git.alt task ls --old)"}#\#}//:/\\:}/ /:})
_describe -t task-id 'task id' tasks
}
_git_alt_all_tasks()
{
local -a tasks
tasks=(${${${${(f)"$(_call_program any-task-id git.alt task ls --all)"}#\#}//:/\\:}/ /:})
_describe -t any-task-id 'task id' tasks
}
_git_alt_subtasks()
{
local -a subtasks
# Assumes that task id comes right before subtask id
# Needs patched girar on server side
subtasks=(${${(f)"$(_call_program any-task-id git.alt task show --brief ${words[(( CURRENT - 1 ))]})"}# })
_describe -t subtask-id 'subtask id' subtasks
}
_git_alt_package_repositories()
{
local -a repos
repos=( ${${${${${${${${(M)${${(f)"$(_call_program package-repository git.alt ls packages)"}:#total *}:#d*}##[^ ]## ##}##[^ ]## ##}##[^ ]## ##}##[^ ]## ##}##[^ ]## ##}##[^ ]## ##}%.git} )
_describe -t package-repository 'package repository' repos
}
_git_alt_package_tags()
{
local -a tags
tags=( ${(M)${${${${(f)"$(_call_program package-tag git ls-remote -t git.alt:packages/${words[(( CURRENT - 1 ))]}.git)"}:#*\^\{\}}##* }#refs/tags/}:#*-alt*} )
_describe -t package-tag 'package tag' tags
}
_git_alt_srpms()
{
local -a srpms
srpms=( ${${${${${${${${(M)${${(f)"$(_call_program source-rpm git.alt ls incoming)"}:#total *}:#*.src.rpm}##[^ ]## ##}##[^ ]## ##}##[^ ]## ##}##[^ ]## ##}##[^ ]## ##}##[^ ]## ##}%.git} )
_describe -t source-rpm 'source rpm' srpms
}
local -a args reply
args=(
# Command word. Don't care what that is.
/$'[^\0]#\0'/
)
local -a charset_args
charset_args=(
/$'[^\0]#\0'/ ':git-repository:path to git repository:_git_alt_directories'
/$'[^\0]#\0'/ ':character-set:charset:'
)
local -a clone_args
clone_args=(
/$'[^\0]#\0'/ ':git-repository:source git repository:_git_alt_directories'
/$'[^\0]#\0'/ ':git-directory:destination directory:_git_alt_directories'
)
local -a find_package_args
find_package_args=(
/$'[^\0]#\0'/ ':pattern:search pattern:'
)
local -a init_db_args
init_db_args=(
/$'((packages|private|public)/)#[A-Za-z0-9][-A-Za-z0-9_.]##\0'/ ':repository-name:repository name:'
)
local -a ls_args
ls_args=(
/$'[^\0]#\0'/ ':git-directory:git.alt directory:_git_alt_directories'
)
local -a mv_db_args
mv_db_args=(
/$'[^\0]#\0'/ ':git-repository:source git repository:_git_alt_directories'
/$'[^\0]#\0'/ ':git-directory:destination directory:_git_alt_directories'
)
local -a rm_db_args
rm_db_args=(
/$'[^\0]#\0'/ ':git-repository:git repository:_git_alt_directories'
)
local -a task_ls_args
_regex_words \
task-ls-args "task ls argument" \
'--all:list all tasks'
task_ls_args=( '(' "$reply[@]" '|' ')' )
local -a task_id_arg
task_id_arg=(
/$'[[:digit:]]##\0'/ ':task-id:task id:_git_alt_tasks'
)
local -a task_any_id_arg
task_any_id_arg=(
/$'[[:digit:]]##\0'/ ':task-id:task id:_git_alt_all_tasks'
)
local -a binary_repo_arg
_regex_words \
binary-repositories "binary repository" \
'sisyphus:Sisyphus' \
'5.0:branch/5.0' \
'4.1:branch/4.1' \
'4.0:branch/4.0'
binary_repo_arg=("$reply[@]")
local -a repo_tag_args
repo_tag_args=(
/$'[A-Za-z0-9][-A-Za-z0-9_.]##\0'/ ':package-repository:package repository:_git_alt_package_repositories'
/$'[^\0]##-alt[^\0]##\0'/ ':package-tag:package tag:_git_alt_package_tags'
)
local -a source_rpm_arg
source_rpm_arg=(
/$'[^\0]##.src.rpm\0'/ ':source-rpm:source rpm:_git_alt_srpms'
)
local -a package_name_arg
package_name_arg=(
/$'[^@\0]##\0'/ ':package-name:package name:'
)
local -a group_name_arg
group_name_arg=(
/$'@[a-z_0-9]##\0'/ ':group-id:group name:'
)
local -a login_arg
login_arg=(
/$'[a-z_0-9]##\0'/ ':user-id:maintainer:'
)
local -a task_add_subcmd
_regex_words \
task-add-commands "task add command" \
'repo:build from git repository:$repo_tag_args' \
'srpm:source rpm name:$source_rpm_arg' \
'del:delete package:$package_name_arg' \
'copy:copy from another repository:$package_name_arg $binary_repo_arg'
task_add_subcmd=( '(' $task_id_arg '|' ')' "$reply[@]")
local -a task_subtask_id_arg
task_subtask_id_arg=(
/$'[[:digit:]]##\0'/ ':subtask-id:subtask id:_git_alt_subtasks'
)
local -a task_share_args
_regex_words \
task-share-command "task share command" \
'status:show status' \
'enabled:share task' \
'disabled:unshare task'
task_share_args=(
'(' $task_id_arg '|' ')'
"$reply[@]"
)
local -a task_commands
_regex_words \
task-commands "task command" \
'ls:list tasks:$task_ls_args' \
'show:show task:\( $task_any_id_arg \| \)' \
'new:new task:$binary_repo_arg' \
'add:add subtask:$task_add_subcmd' \
'delsub:delete subtask:$task_id_arg $task_subtask_id_arg' \
'run:run task:\( $task_id_arg \| \)' \
'share:share task:$task_share_args' \
'approve:approve subtask:$task_any_id_arg $task_subtask_id_arg' \
'rm:delete task:\( $task_id_arg \| \)'
task_commands=("$reply[@]")
local -a build_args
_regex_words \
build-options "build option" \
'-b:binary repository name:$binary_repo_arg'
build_args=(
'(' "$reply[@]" '|' ')'
'('
/$'srpm\0'/ ':build-command:build command:(( srpm:build\ source\ rpm ))'
$source_rpm_arg
'|'
$repo_tag_args
')' '#'
)
local -a acl_login_group_arg
acl_login_group_arg=(
'('
$group_name_arg
'|'
$login_arg
')'
)
local -a acl_package_group_arg
acl_package_group_arg=(
'('
$group_name_arg
'|'
$package_name_arg
')'
)
local -a timestamp
timestamp=(
/$'[[:digit:]]##\0'/ ':timestamp:timestamp:'
)
local -a acl_nmu_cmds
_regex_words \
acl-nmu-command "acl nmu command" \
'show:show nmu status' \
'add:add nmu rights:$login_arg $timestamp $timestamp' \
'del:delete nmu rights:$login_arg $timestamp $timestamp'
acl_nmu_cmds=("$reply[@]")
local -a acl_cmds
_regex_words \
acl-command "acl command" \
'nmu:nmu management:$acl_nmu_cmds' \
'check:check acl' \
'show:show acl' \
'add:add acl:\( $acl_login_group_arg \# \)' \
'del:delete acl:\( $acl_login_group_arg \# \)' \
'leader:set leader:$acl_login_group_arg' \
'replace:replace acl:\( $acl_login_group_arg \# \)'
acl_cmds=("$reply[@]")
local -a acl_list_arg
_regex_words \
acl-option "acl option" \
'--list:list binary repositories'
acl_list_arg=("$reply[@]")
local -a acl_args
acl_args=(
'('
$acl_list_arg
'|'
$binary_repo_arg
$acl_package_group_arg
$acl_cmds
')'
)
_regex_words \
commands "git.alt command" \
'help:show git.alt command reference' \
'charset:set default character encoding for repository:$charset_args' \
'clone:clone repository:$clone_args' \
'find-package:search repository:$find_package_args' \
'init-db:create new repository:$init_db_args' \
'ls:list git.alt directory:$ls_args' \
'mv-db:rename/move repository:$mv_db_args' \
'quota:show user quota information' \
'rm-db:delete repository:$rm_db_args' \
'task:manage tasks:$task_commands' \
'build:build package:$build_args' \
'acl:manage package access control lists:$acl_args'
args+=("$reply[@]")
_regex_arguments _git_alt "${args[@]}"
_git_alt "$@"
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: Digital signature
URL: <http://lists.altlinux.org/pipermail/devel/attachments/20090517/511508db/attachment-0001.bin>
Подробная информация о списке рассылки Devel