ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/scripts/_scram
Revision: 1.4
Committed: Wed Feb 28 12:41:28 2007 UTC (18 years, 2 months ago) by sashby
Branch: MAIN
CVS Tags: HEAD_SM_071214, V1_1_0, v110p1, V110p6, V110p5, V110p4
Branch point for: HEAD_BRANCH_SM_071214
Changes since 1.3: +2 -9 lines
Log Message:
Updates to doc.

File Contents

# Content
1 #compdef scram scramv1
2 # $Id: _scram,v 1.3 2006/09/11 13:39:48 sashby Exp $
3 #
4 _scram()
5 {
6 _arguments -s \
7 '-h[show help]' \
8 '-v[version]' \
9 '-d[debug mode]' \
10 '-n[no return]' \
11 '-arch:supported architectures:(slc3_ia32_gcc323 slc3_ia32_gcc323_dbg slc4_ia32_gcc345 slc4_ia32_gcc345_dbg osx104_ia32_gcc40)' \
12 '*::scram command:_scram_command'
13 }
14
15 (( $+functions[_scram_command] )) ||
16 _scram_command ()
17 {
18 local _scram_cmds
19 _scram_cmds=(version arch setup runtime build list project tool install remove db config urlget gui)
20
21 if (( CURRENT == 1 )); then
22 _tags _scram_cmds && { compadd "$@" -a _scram_cmds }
23 else
24 local curcontext="$curcontext"
25 cmd="$words[1]"
26 if (( $#cmd )); then
27 curcontext="${curcontext%:*:*}:scram-${cmd}:"
28 _scram_$cmd
29 else
30 _message "unknown scram command: $words[1]"
31 fi
32 fi
33 }
34
35 (( $+functions[_scram_version] )) ||
36 _scram_version()
37 {
38 _arguments -s \
39 '-h[show help for the version command]:print help for this command' \
40 '-c[show CVS parameters for SCRAM downloads]' \
41 '-i[show CVS commit information]' \
42 '*::specify a version to download:(V1_0_1 V1_0_2 V1_0_3)'
43 }
44
45 (( $+functions[_scram_arch] )) ||
46 _scram_arch()
47 {
48 _arguments -s \
49 '-h[show help for the arch command]:print help for this command'
50 }
51
52 (( $+functions[_scram_setup] )) ||
53 _scram_setup()
54 {
55 # scram setup [-i] [-f tools.conf] [toolname] [[version] [url]]
56 _arguments -s \
57 - set1 \
58 '-h[show help for the setup command]:print help for this command' \
59 - set2 \
60 '-i[interactive setup mode]' \
61 '-f[file for tool default settings]:tool config defaults:_files -g \*.conf' \
62 "*::tool list:_scram_tools_and_versions"
63 }
64
65 (( $+functions[_scram_runtime] )) ||
66 _scram_runtime()
67 {
68 _arguments -s \
69 - set1 \
70 '-h[show help for the runtime command]:print help for this command' \
71 - set2 \
72 '(-c -w)-s[Bourne-like shell environment]' \
73 '(-s -w)-c[TCSH shell environment]' \
74 '(-c -s)-w[Win32 shell environent]' \
75 '-d[dump the current environment]:filename' \
76 - set3 \
77 '(-c -w)-s[Bourne-like shell environment]' \
78 '(-s -w)-c[TCSH shell environment]' \
79 '(-c -s)-w[Win32 shell environent]' \
80 '-f:read an environment from a file:_files -g \*.env'
81 }
82
83 (( $+functions[_scram_tool] )) ||
84 _scram_tool()
85 {
86 local expl
87 _arguments -s \
88 '-h[show help for the tool command]:print help for this command'
89
90 if (( $CURRENT == 2 )); then
91 local tooltags
92 tooltags=(list info tag remove template)
93 _wanted cmds expl 'tool sub-command' compadd -a tooltags
94 elif (( $CURRENT == 3 )); then
95 local _scramtools
96 typeset -gA _scramtools
97
98 if (( ! $#_scramtools )); then
99 _scramtools=($(_call_program commands scram tool list | grep "^ " 2>&1))
100 fi
101
102 case "$words[2]" in
103 list)
104 _message 'list configured tools'
105 ;;
106 info|remove|tag)
107 if (( $#_scramtools )); then
108 _wanted tools expl 'list of configured tools' compadd ${(k)_scramtools}
109 else
110 _message 'No tools: probably not in a project area'
111 fi
112 ;;
113 template)
114 local tmpltypes
115 tmpltypes=(compiler basic)
116 _wanted tmpl expl 'template type to download' compadd -a tmpltypes
117 ;;
118 esac
119 elif (( $CURRENT == 4 )); then
120 local _toolstags
121
122 if (( ! $#_toolstags )); then
123 _toolstags=($(_call_program commands scram tool tag $words[3] 2>&1))
124 fi
125 _wanted ttags expl "tags defined for $words[3]" compadd -a _toolstags
126 fi
127 }
128
129 (( $+functions[_scram_build] )) ||
130 _scram_build()
131 {
132 local makeopts
133 makeopts=(
134 '-n[print the commands that would be executed but do not run them]'
135 '--printdir[print the working directory before and after entering it]'
136 '--printdb[print the data base of rules after scanning makefiles, then build as normal]'
137 '-j[the number of processes to run simultaneously]'
138 '-k[continue for as long as possible after an error]'
139 '-s[do not print any output]'
140 '-d[run gmake in debug mode]'
141 )
142
143 _arguments -s \
144 '-h[show help for the build command]:print help for this command' \
145 '-v[show compilation command]' \
146 '-r[reset cache]' \
147 '-f[skip cache scan]' \
148 '-t[dry run]' \
149 '-w-[graphing mode type]:graphing mode:_scram_graphing' \
150 '--xmlb[Read XML BuildFiles]' \
151 "$makeopts[@]" \
152 '*::targets:(release release-build shared bin test)'
153 }
154
155 (( $+functions[_scram_list] )) ||
156 _scram_list()
157 {
158 _arguments -s \
159 '-h[show help for the list command]:print help for this command' \
160 '-c[show a compact list]' \
161 '-o[use old-style listing (i.e. all projects)]' \
162 '*::SCRAM project:_scram_projects_and_versions'
163 }
164
165 (( $+functions[_scram_project] )) ||
166 _scram_project()
167 {
168 # scram project [-t] [-d <area>] [-n <dir>] [-f <tools.conf>] <projecturl> [<projectversion>]
169 _arguments \
170 - set1 \
171 '-h[show help for the project command]:print help for this command' \
172 - set2 \
173 '-t[download project templates]:download project templates' \
174 - set3 \
175 '-f:file for tool defaults:_files -g \*.conf' \
176 '-b[bootstrap files]:bootstrap:_files -g conf\*/boot\*' \
177 - set4 \
178 '-d:installation directory:_files -/' \
179 '-n[area name]:area name' \
180 '*:::SCRAM project:_scram_projects_and_versions'
181 }
182
183 (( $+functions[_scram_install] )) ||
184 _scram_install()
185 {
186 _arguments -s \
187 '-h[show help for the install command]:print help for this command' \
188 '-f[force the installation]' \
189 '*:::optional project label and version'
190 }
191
192 (( $+functions[_scram_remove] )) ||
193 _scram_remove()
194 {
195 _arguments -s \
196 '-h[show help for the remove command]:print help for this command' \
197 '-f[force the installation]' \
198 '*:::SCRAM project:_scram_projects_and_versions'
199 }
200
201 (( $+functions[_scram_db] )) ||
202 _scram_db()
203 {
204 _arguments -s \
205 '-h[show help for the db command]:print help for this command' \
206 '-link[link to a SCRAM database]:linkdb:_files -g \*\*/project.lookup' \
207 '-unlink[remove linked SCRAM databases]:removedb:_scram_db_unlink' \
208 '-show[show linked SCRAM databases]'
209 }
210
211 (( $+functions[_scram_config] )) ||
212 _scram_config()
213 {
214 _arguments -s \
215 '-h[show help for the config command]:print help for this command' \
216 '-t[dump list of configured tools]' \
217 '-f[dump tools and project config]'
218 }
219
220 (( $+functions[_scram_urlget] )) ||
221 _scram_urlget()
222 {
223 _arguments -s \
224 '-h[show help for the urlget command]:print help for this command' \
225 '*::specify a scram document URL:( http:// file: cvs:// )'
226 }
227
228 (( $+functions[_scram_gui] )) ||
229 _scram_gui()
230 {
231 _arguments -s \
232 '-h[show help for the gui command]:print help for this command' \
233 '-e[edit metadata]' \
234 '-s[show metadata information]' \
235 '*::metadata type:(tool compiler)'
236 }
237
238 ############# Auxiliary functions ##############
239
240 (( $+functions[_scram_tools_and_versions] )) ||
241 _scram_tools_and_versions()
242 {
243 local _scramtools expl
244 typeset -gA _scramtools
245
246 if (( ! $#_scramtools )); then
247 _scramtools=($(_call_program commands scram tool list | grep "^ " 2>&1))
248 fi
249
250 if (( $CURRENT == 2 )); then
251 if (( $#_scramtools )); then
252 local _version
253 _version=(${_scramtools[$words[1]]})
254 _wanted projectver expl 'select tool version' compadd -a _version
255 else
256 _message 'No tools: probably not in a project area'
257 fi
258 elif (( $CURRENT == 3 )); then
259 local _urls
260 _urls=(http:// cvs:// file:./)
261 _wanted urls expl 'ToolDoc URLs' compadd $_urls
262 else
263 if (( $#_scramtools )); then
264 _wanted tools expl 'configured tools' compadd ${(k)_scramtools}
265 else
266 _message 'No tools: probably not in a project area'
267 fi
268 fi
269 }
270
271 (( $+functions[_scram_db_unlink] )) ||
272 _scram_db_unlink()
273 {
274 local expl
275
276 _dbs=( $(_call_program dbs scram db -show | grep lookup | grep -v Current 2>/dev/null) )
277
278 if (( $#_dbs ));then
279 _wanted scramdb expl 'remove database' compadd -a _dbs
280 else
281 _message 'No databases linked'
282 fi
283 }
284
285 (( $+functions[_scram_graphing] )) ||
286 _scram_graphing()
287 {
288 local opts
289 opts=('package' 'global')
290 _wanted graph-mode expl 'graphing mode' compadd -P '=' $opts
291 }
292
293 (( $+functions[_scram_projects_and_versions] )) ||
294 _scram_projects_and_versions()
295 {
296 local expl _projects _versions
297
298 if (( $CURRENT == 2 )); then
299 _versions=( $(_call_program pversions scram l -c $words[1] | awk '{print $2}' |sort|uniq 2>/dev/null) )
300 _wanted projectver expl 'select project version' compadd -a _versions
301 else
302 _projects=( $(_call_program pversions scram l -c | awk '{print $1}' |sort|uniq 2>/dev/null) )
303 if (( $#_projects )); then
304 _wanted projects expl 'SCRAM project' compadd -a _projects
305 else
306 _message 'No installed projects'
307 fi
308 fi
309 }
310
311
312 ################ Main ###################
313 # Run the function with args passed down:
314 #########################################
315 _scram "$@"
316