1#compdef prcs 2 3local curcontext="$curcontext" state line subcmds ret=1 4typeset -A opt_args 5 6# lookup project names in the repository 7# (this does not handle subprojects) 8 9(( $+functions[_prcs_projects] )) || 10_prcs_projects() { 11 local expl 12 13 _wanted prcs-projects expl 'project name' compadd "$@" - \ 14 ${~opt_args[-R]:-${opt_args[--repository]:-${PRCS_REPOSITORY:-~/PRCS}}}/*(/:t) 15} 16 17# standard options for all subcommands 18 19(( $+functions[_prcs_arguments] )) || 20_prcs_arguments() { 21 _arguments -s \ 22 '(-f --force)'{-f,--force}'[resolve interactive queries in some fixed way]' \ 23 '(-h -H --help)'{-h,-H,--help}'[print out help]' \ 24 '(-j --jobs)'{-j,--jobs=}'[spawn many child processes at once]:number:' \ 25 '(-l -L --long-format --long-long-format)'{-l,--long-format}'[long format]' \ 26 '(-l -L --long-format --long-long-format)'{-L,--long-long-format}'[longer format]' \ 27 '(-n --no-action)--no-action[show what would happen but leave files unchanged]' \ 28 '(-q --quiet)'{-q,--quiet}'[suppress normal informational messages]' \ 29 "--plain-format[don't break lines at screen width]" \ 30 '(-R --repository)'{-R,--repository=}'[specify the repository directory]:directory:_files -/' \ 31 "$@" 32} 33 34_arguments -C \ 35 '(* -)'{-h,-H,--help}'[print out help]' \ 36 '(* -)--version[display program version]' \ 37 '*:: :->subcmd' && ret=0 38 39if (( CURRENT == 1 )); then 40 subcmds=( 41 'admin:admin subcommand' 42 'checkin:checkin project revision' 43 'checkout:checkout project revision' 44 'config:verify configuration' 45 'delete:delete named revision of project' 46 'depopulate:remove named files from project descriptor' 47 'diff:show differences between two revisions' 48 'execute:execute a command for each file in a project' 49 'info:print information about versions of project' 50 'merge:reconcile differences between working files and another revision' 51 'package:package the project and all its revisions into packagefile' 52 'populate:add named files to project descriptor' 53 'rekey:set keywords in selected files' 54 'unpackage:unpackage project in packagefile' 55 ) 56 57 _describe -t commands 'prcs command' subcmds && ret=0 58 return ret 59fi 60 61curcontext="${curcontext%:*}-$words[1]:" 62 63case "$words[1]" in 64 admin) 65 if (( CURRENT == 2 )); then 66 subcmds=( 67 'access:set the access permissions on the repository' 68 'compress:instruct PRCS to save disk space for project' 69 'init:create a repository entry' 70 'pdelete:delete a repository entry' 71 'pinfo:list all projects in the repository' 72 'prename:rename a repository entry' 73 'rebuild:reconstruct PRCS data files in the repository' 74 'uncompress:instruct PRCS to save time in processing project' 75 ) 76 _describe -t commands 'admin subcommand' subcmds 77 else 78 shift words 79 (( --CURRENT )) 80 curcontext="${curcontext%:*}-$words[1]:" 81 case "$words[1]" in 82 access|compress|init|pdelete|prename|rebuild) 83 _prcs_arguments ':project name:_prcs_projects' 84 ;; 85 pinfo) 86 _prcs_arguments 87 ;; 88 uncompress) 89 _prcs_arguments \ 90 '-i[expand the entire project immediately]' \ 91 ':project name:_prcs_projects' 92 ;; 93 *) 94 _message "unknown prcs administrative subfunction: $words[1]" 95 ;; 96 esac 97 fi 98 ;; 99 checkin) 100 _prcs_arguments \ 101 '(-r --revision)'{-r+,--revision=}'[specify version of the project]:revision:' \ 102 '(-s --skilled-merge)'{-s,--skilled-merge}'[turn off most of the safety features of merge]' \ 103 ':project name:_prcs_projects' \ 104 '*:file or directory:_files' 105 ;; 106 checkout) 107 _prcs_arguments \ 108 '(-r --revision)'{-r+,--revision=}'[specify version of the project]:revision:' \ 109 '(-p --preserve)'{-p,--preserve}'[preserve permissions on files that are checked out]' \ 110 '(-u --unlink)'{-u,--unlink}"[don't overwrite symbolic link references]" \ 111 '(-P --exclude-project-file)'{-P,--exclude-project-file}"[don't checkout the project file]" \ 112 ':project name:_prcs_projects' \ 113 '*:file or directory:_files' 114 ;; 115 config) 116 _prcs_arguments 117 ;; 118 delete) 119 _prcs_arguments \ 120 '(-r --revision)'{-r+,--revision=}'[specify version of the project]:revision:' \ 121 ':project name:_prcs_projects' 122 ;; 123 depopulate) 124 _prcs_arguments \ 125 ':project name:_prcs_projects' \ 126 '*:file or directory:_files' 127 ;; 128 diff) 129 _prcs_arguments \ 130 '*'{-r+,--revision=}'[specify version of the project]:revision:' \ 131 '(-k --keywords)'{-k,--keywords}'[compare keywords too]' \ 132 '(-N --new)'{-N,--new}'[compare new files against empty files]' \ 133 '(-P --exclude-project-file)'{-P,--exclude-project-file}"[don't diff the project file]" \ 134 '--[introduce diff options]:*::diff options:= _diff_options ${PRCS_DIFF_COMMAND:-diff}' \ 135 ':project name:_prcs_projects' \ 136 '*:file or directory:_files' 137 ;; 138 execute) 139 _prcs_arguments \ 140 '(-r --revision)'{-r+,--revision=}'[specify version of the project]:revision:' \ 141 '--pre[list directories first]' \ 142 '(--pipe)--all[execute command once, with all files as arguments]' \ 143 '(--all)--pipe[supply file contents as the standard input]' \ 144 '--match[execute command on files matching a pattern]:pattern:' \ 145 '--not[execute command on files not matching a pattern]:pattern:' \ 146 '--:command: _command_names -e:*::arguments: _normal' \ 147 ':project name:_prcs_projects' \ 148 '*:file or directory:_files' 149 ;; 150 info) 151 _prcs_arguments \ 152 '(-r --revision)'{-r+,--revision=}'[specify version of the project]:revision:' \ 153 '--sort=[set sorting type]:sorting type:(version date)' \ 154 ':project name:_prcs_projects' \ 155 '*:file or directory:_files' 156 ;; 157 merge) 158 _prcs_arguments \ 159 '(-r --revision)'{-r+,--revision=}'[specify version of the project]:revision:' \ 160 '(-s --skilled-merge)'{-s,--skilled-merge}'[turn off most of the safety features of merge]' \ 161 '(-u --unlink)'{-u,--unlink}"[don't overwrite symbolic link references]" \ 162 ':project name:_prcs_projects' \ 163 '*:file or directory:_files' 164 ;; 165 package) 166 _prcs_arguments \ 167 '(-r --revision)'{-r+,--revision=}'[specify version of the project]:revision:' \ 168 '(-z --compress)'{-z,--compress=}'[compress the output]' \ 169 ':project name:_prcs_projects' \ 170 ':file:_files' 171 ;; 172 populate) 173 _prcs_arguments \ 174 '(-d --delete)'{-d,--delete=}'[perform optional deletions]' \ 175 ':project name:_prcs_projects' \ 176 '*:file or directory:_files' 177 ;; 178 rekey) 179 _prcs_arguments \ 180 '(-u --unlink)'{-u,--unlink}"[don't overwrite symbolic link references]" \ 181 ':project name:_prcs_projects' 182 ;; 183 unpackage) 184 _prcs_arguments \ 185 ':file:_files' \ 186 ':project name:_prcs_projects' 187 ;; 188 *) 189 _message "unknown prcs command: $words[1]" 190 ;; 191esac 192