diff options
| author | Clint Adams <clint@users.sourceforge.net> | 2004-04-15 03:56:39 +0000 |
|---|---|---|
| committer | Clint Adams <clint@users.sourceforge.net> | 2004-04-15 03:56:39 +0000 |
| commit | dd9929a30e1851cd7cc31f19a640bf93bd36db91 (patch) | |
| tree | 3d86f42069d88d7cdee28e9eddf580c346b858c6 /Completion/Unix/Command | |
| parent | * Jay Berkenbilt: 19769: Completion/Unix/Command/_rsync: (diff) | |
| download | zsh-dd9929a30e1851cd7cc31f19a640bf93bd36db91.tar zsh-dd9929a30e1851cd7cc31f19a640bf93bd36db91.tar.gz zsh-dd9929a30e1851cd7cc31f19a640bf93bd36db91.tar.bz2 zsh-dd9929a30e1851cd7cc31f19a640bf93bd36db91.tar.lz zsh-dd9929a30e1851cd7cc31f19a640bf93bd36db91.tar.xz zsh-dd9929a30e1851cd7cc31f19a640bf93bd36db91.tar.zst zsh-dd9929a30e1851cd7cc31f19a640bf93bd36db91.zip | |
* 19606: Completion/Unix/Command/_tla: switch tla completion to
the version by Jason McCarty, Erik Toubro Nielsen, and Rob Weir.
Diffstat (limited to 'Completion/Unix/Command')
| -rw-r--r-- | Completion/Unix/Command/_tla | 973 |
1 files changed, 966 insertions, 7 deletions
diff --git a/Completion/Unix/Command/_tla b/Completion/Unix/Command/_tla index 4ae56a1d6..82af25899 100644 --- a/Completion/Unix/Command/_tla +++ b/Completion/Unix/Command/_tla @@ -1,11 +1,970 @@ #compdef tla -local -a subcmds +local arg_call opts_std opt_archive \ + opt_silent opt_quiet opt_report opt_verbose opt_debug opts_verbosity \ + opt_cache opt_dir opt_delete opt_errname opts_tag_method opt_readme \ + opt_reverse opt_summary opt_creator opt_date opt_full opt_dest opt_forward \ + opt_sparse opt_non_sparse opt_link opt_library +opts_std=( + '--version[print version info]' + '--help[display help]' +) +opt_archive=( + '--archive[specify the default archive name]:archive:_tla_archives' +) +opt_library_archive=( + '--archive[specify the default archive name]:archive:_tla_archives --library' +) +opt_silent=('(--quiet --report --verbose --debug)--silent[suppress messages]') +opt_quiet=('(--silent --report --verbose --debug)--quiet[brief output]') +opt_report=('(--silent --quiet --verbose --debug)--report[default output]') +opt_verbose=('(--silent --quiet --report --debug)--verbose[maximal output]') +opt_debug=('(--silent --quiet --report --verbose)--debug[debugging output]') +opts_verbosity=($opt_silent $opt_quiet $opt_report $opt_verbose $opt_debug) +opt_cache=( + '--cache[specify directory for locally cached revisions]:directory: _files -/' +) +opt_dir=('--dir[operate on project tree in DIR]:DIR:_files -/') +opt_delete=('--delete[unspecify]') +opt_errname=('--errname[specify program name for errors]:program:_files') +opts_tag_method=( + '--explicit[use explicit file tags]' + '--implicit[use implicit file tags]' + '--tagline[use tagline file tags]' + '--names[use name-based file tags]' +) +opt_readme=('--readme[save FILE as the README for this archive]:file:_files') +opt_reverse=('--reverse[print in reverse order]') +opt_summary=('--summary[print a summary of each patch]') +opt_creator=('--creator[print the creator id of each patch]') +opt_date=('--date[print the date of each patch]') +opt_full=('--full[print full names of patch levels]') +opt_dest=( + '--dest[create/modify DEST instead of the project tree]:DEST:_files -/' +) +opt_forward=('--forward[pass the --forward option to `patch'\'']') +opt_sparse=('(--non-sparse)--sparse[don'\''t fill in gaps in the library]') +opt_non_sparse=('(--sparse)--non-sparse[fill in gaps in the library]') +opt_link=('--link[hardlink files to revision library instead of copying]') +opt_library=('--library[ensure the revision is in a revision library]') -subcmds=(${${${(M)${(f)"$(_call_program tla tla help)"}:#[ ]* : *}% : *}##[ ]##} ) +(( $+functions[_tla_archives] )) || +_tla_archives () { + local expl completions library name_arg='-n' + if [[ -n $argv[(k)--library] ]]; then + library='library-' + # remove parameter from $@ before calling compadd + argv[(k)--library]=() + name_arg= + fi + completions=($(_call_program tla tla ${library:-}archives $name_arg)) + _description -V archives expl "${library:-}archives" + compadd "$@" "$expl[@]" -- "$completions[@]" +} -if (( CURRENT == 2 )); then - _describe -t commands 'tla command' compadd - "$subcmds[@]" -else - _files -fi +(( $+functions[_tla_categories] )) || +_tla_categories () { _tla_namespace 1 "$argv[@]" } + +(( $+functions[_tla_branches] )) || +_tla_branches () {_tla_namespace 2 "$argv[@]" } + +(( $+functions[_tla_versions] )) || +_tla_versions () { _tla_namespace 3 "$argv[@]" } + +(( $+functions[_tla_revisions] )) || +_tla_revisions () { _tla_namespace 4 "$argv[@]" } + +(( $+functions[_tla_local_revisions] )) || +_tla_local_revisions () { + local expl1 expl2 tree_version=`tla tree-version` + _description -V applied-patches expl1 "patches from this version" + _description -V other-patches expl2 "patches from other versions" + compadd "$expl1[@]" `tla logs` + compadd "$expl2[@]" `tla logs --full $(tla log-versions | grep -v $tree_version)` + # This is incredibly slow. + # Should complete based on -A, -R, -d +} + +(( $+functions[_tla_namespace] )) || +_tla_namespace () { #double as arch_namespace_categories +# takes an integer argument specifying how many components: +# 1: category +# 2: branch +# 3: version +# 4: revision + local suffix expl archive=`tla my-default-archive` + local trailing_dashes=0 + [[ -n $argv[(k)--trailing-dashes] ]] && trailing_dashes=1 + local library + [[ -n $argv[(k)--library] ]] && library='library-'; + local exclude_library_revisions=0 + [[ -n $argv[(k)--exclude-library-revisions] ]] && exclude_library_revisions=1 + + if [ $1 -gt 1 ] || (( trailing_dashes )); then + suffix=(-q -S --) + fi + if [[ $PREFIX = */* ]]; then + compset -P '*/' + archive=${IPREFIX%/*} + _description -V categories expl "${library:-}categories in $archive" + compadd $suffix "$expl[@]" `tla ${library:-}categories -A $archive` + elif [ -z $IPREFIX ]; then + for (( i = 2 ; i < CURRENT ; i++ )); do + if [ $words[$i] = -A ] || [ $words[$i] = --archive ]; then + archive=$words[(($i + 1))] + break + fi + done + + _description -V categories expl "${library:-}categories in $archive" + compadd "$expl[@]" $suffix `tla ${library:-}categories -A $archive` + _tla_archives -S / ${library:+--library} + fi + if [ $1 -gt 1 ] && [[ $PREFIX != *@* ]] && [[ $PREFIX = *--* ]]; then + #this match could be better + _tla_namespace_branches $(($1 - 1)) + fi +} + +(( $+functions[_tla_namespace_branches] )) || +_tla_namespace_branches () { + local suffix expl + if [ $1 -gt 1 ] || (( $trailing_dashes )); then + suffix=(-q -S --) + fi + if [[ $IPREFIX != *-- ]]; then + compset -P 1 '*--' + local category=${IPREFIX%--} + _description -V branches expl "${library:-}branches" + compadd $suffix "$expl[@]" \ + `tla ${library:-}branches -A $archive $category | sed 's/^.*--//'` + fi + if [ $1 -gt 1 ] && [[ $IPREFIX = *-- ]] && [[ $PREFIX = *--* ]]; then + _tla_namespace_versions $(($1 - 1)) + fi +} + +(( $+functions[_tla_namespace_versions] )) || +_tla_namespace_versions () { + local suffix expl + if [ $1 -gt 1 ]; then + suffix=(-q -S --) + fi + if [[ $IPREFIX != *--*-- ]] || [[ $IPREFIX != */*--*-- ]]; then + compset -P 1 '*--' + local branch=${IPREFIX%--} + _description -V versions expl "${library:-}versions" + compadd $suffix "$expl[@]" \ + `tla ${library:-}versions -A $archive $branch | sed 's/^.*--//'` + fi + if [ $1 -gt 1 ] && [[ $IPREFIX = *--*-- ]] && ([[ $IPREFIX = */*--*-- ]] \ + || [[ $PREFIX != */* ]]) && [[ $PREFIX = *--* ]]; then + _tla_namespace_revisions + fi +} + +(( $+functions[_tla_namespace_revisions] )) || +_tla_namespace_revisions () { + local expl + if [[ $IPREFIX != *--*--*-- ]] || [[ $IPREFIX != */*--*--*-- ]]; then + compset -P 1 '*--' + local version=${IPREFIX%--} + _description -V revisions expl "${library:-}revisions" + local completions c + completions=(`tla ${library:-}revisions -A $archive $version | sed 's/^.*--//'`) + (( exclude_library_revisions )) && \ + foreach c ($(tla library-revisions -A $archive $version)); do completions[(k)$c]=(); done + compadd "$expl[@]" -a completions + fi +} + +(( $+functions[_tla_config] )) || +_tla_config () { + + # zsh 4.1.1+ is recommended; 4.0.6 gives the error below when doing + # tla build-config e<TAB> + # _path_files:322: no matches found: configs//e/.(/) + # whereas 4.1.1 completes correctly + + local configdir root ret=1 n expl + + n=$opt_args[(i)(-d|--dir)] + [[ -n "$n" ]] && configdir=$opt_args[$n] + root="$(_call_program tla tla tree-root ${configdir} 2>&1)" + if (( $? )); then + _message -e messages "Error: $root" + return $ret + fi + + if [[ -d "$root/configs" ]]; then + configdir=("$root/configs") + _description files expl '%Bconfig file%b' + _files -W configdir "$expl[@]" && ret=0 + else + _message -e messages "No configs/ directory in tree whose root is $root" + fi + return $ret +} + +(( $+functions[_tla_limit] )) || +_tla_limit () { #presently only does push-mirror style limits + [[ $words[$CURRENT] = *@* ]] && return 1 + + local expl archive=`tla my-default-archive` + + for (( i = 2 ; i < CURRENT ; i++ )); do + if [[ $words[$i] = *@* ]]; then + archive=$words[$i] + if tla archives -n | grep "$archive-SOURCE" > /dev/null; then + archive=$archive-SOURCE + fi + break + fi + done + + _description -V categories expl "categories in $archive" + if [[ $PREFIX != *--* ]]; then + compadd -q -S -- "$expl[@]" `tla categories -A $archive` + else + _tla_namespace_branches 3 + fi +} + +(( $+functions[_tla_tree_or_rev] )) || +_tla_tree_or_rev () { + _alternative 'trees:tree:_files -/' 'revisions:revision:_tla_revisions' +} + +local _arg_call +_arg_call=(_arguments -S -A "-*" $opts_std) + +(( $+functions[_tla_cmd_help] )) || +_tla_cmd_help () { $_arg_call } + +(( $+functions[_tla_cmd_my-id] )) || +_tla_cmd_my-id () { + $_arg_call $opt_errname \ + '--uid[print only the UID portion of the id]' \ + '::id-string:' +} + +(( $+functions[_tla_cmd_my-default-archive] )) || +_tla_cmd_my-default-archive () { + $_arg_call $opt_archive $opt_errname $opt_silent $opt_delete \ + '::archive:_tla_archives' +} + +(( $+functions[_tla_cmd_register-archive] )) || +_tla_cmd_register-archive () { + $_arg_call $opt_delete '--force[overwrite existing location]' \ + '::archive:_tla_archives' ':location:_files -/' +} + +(( $+functions[_tla_cmd_whereis-archive] )) || +_tla_cmd_whereis-archive () { + $_arg_call ':archive:_tla_archives' +} + +(( $+functions[_tla_cmd_archives] )) || +_tla_cmd_archives () { + $_arg_call '--names[print archive names only]' \ + '--exclude-remote[exclude MIRROR and SOURCE archives]' \ + '::regex:' +} + +(( $+functions[_tla_cmd_init-tree] )) || +_tla_cmd_init-tree () { + $_arg_call $opt_archive $opt_dir \ + '--nested[init a nested project tree]' \ + '::version:_tla_versions' +} + +(( $+functions[_tla_cmd_tree-root] )) || +_tla_cmd_tree-root () { + $_arg_call $opt_silent '--accurate[error for mid-txn trees]' \ + '::directory:_files -/' +} + +(( $+functions[_tla_cmd_tree-version] )) || +_tla_cmd_tree-version () { $_arg_call '::directory:_files -/' } + +(( $+functions[_tla_cmd_set-tree-version] )) || +_tla_cmd_set-tree-version () { + $_arg_call $opt_archive $opt_dir ':version:_tla_versions' +} + +(( $+functions[_tla_cmd_build-config] )) || +_tla_cmd_build-config () { + $_arg_call $opt_dir $opt_sparse $opt_link $opt_library \ + '--no-pristines[don'\''t create pristine copies]' \ + '--release-id[overwrite ./=RELEASE-ID for this config]' \ + ':config:_tla_config' +} + +(( $+functions[_tla_cmd_cat-config] )) || +_tla_cmd_cat-config () { + $_arg_call $opt_dir \ + '--output[write the output as config CFG]:CFG:_tla_config' \ + '--force[overwrite an exiting config (with --output)]' \ + '--snap[show current patch levels of subtree packages]' \ + ':config:_tla_config' +} + +(( $+functions[_tla_cmd_undo] )) || +_tla_cmd_undo () { + $_arg_call $opt_archive $opt_quiet $opt_dir $opt_forward \ + '(--no-output)--output[save changeset in DIR]:DIR:_files -/' \ + '(--output)--no-output[do not save the changeset]' \ + '::revision:_tla_revisions' +} + +(( $+functions[_tla_cmd_redo] )) || +_tla_cmd_redo() { + $_arg_call $opt_quiet $opt_dir $opt_forward \ + '--keep[do not delete the patch]' \ + '::changeset:_files -/' +} + +(( $+functions[_tla_cmd_changes] )) || +_tla_cmd_changes () { + $_arg_call $opt_archive $opt_verbose $opt_quiet $opt_dir \ + '--output[save changeset in DIR]:DIR:_files -/' \ + '--diffs[include diffs in the output]' \ + '(--output)--keep[don'\''t remove the output directory]' \ + '::revision:_tla_revisions' + # ':separator:(--)' '*::limit:_files' + #don't understand the limit usage +} + +(( $+functions[_tla_cmd_file-diffs] )) || +_tla_cmd_file-diffs () { + $_arg_call $opt_archive '--new-file[treat missing file as empty]' \ + ':file:_files' '::revision:_tla_revisions' +} + +(( $+functions[_tla_cmd_file-find] )) || +_tla_cmd_file-find () { + $_arg_call $opt_archive \ + '--new-file[print missing file as `/dev/null'\'']' \ + ':file:_files' '::revision:_tla_revisions' +} + |
