1 |
sashby |
1.1 |
#compdef scram
|
2 |
|
|
# $Id: _scram,v 1.6 2005/03/24 17:17:06 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:(rh73_gcc323 slc3_ia32_gcc323)' \
|
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)
|
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_0 V1_0_1)'
|
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 |
|
|
"$makeopts[@]" \
|
151 |
|
|
'*::targets:(shared module python bin app)'
|
152 |
|
|
}
|
153 |
|
|
|
154 |
|
|
(( $+functions[_scram_list] )) ||
|
155 |
|
|
_scram_list()
|
156 |
|
|
{
|
157 |
|
|
_arguments -s \
|
158 |
|
|
'-h[show help for the list command]:print help for this command' \
|
159 |
|
|
'-c[show a compact list]' \
|
160 |
|
|
'-o[use old-style listing (i.e. all projects)]' \
|
161 |
|
|
'*::SCRAM project:_scram_projects_and_versions'
|
162 |
|
|
}
|
163 |
|
|
|
164 |
|
|
(( $+functions[_scram_project] )) ||
|
165 |
|
|
_scram_project()
|
166 |
|
|
{
|
167 |
|
|
# scram project [-t] [-d <area>] [-n <dir>] [-f <tools.conf>] <projecturl> [<projectversion>]
|
168 |
|
|
_arguments \
|
169 |
|
|
- set1 \
|
170 |
|
|
'-h[show help for the project command]:print help for this command' \
|
171 |
|
|
- set2 \
|
172 |
|
|
'-t[download project templates]:download project templates' \
|
173 |
|
|
- set3 \
|
174 |
|
|
'-f:file for tool defaults:_files -g \*.conf' \
|
175 |
|
|
'-b[bootstrap files]:bootstrap:_files -g conf\*/boot\*' \
|
176 |
|
|
- set4 \
|
177 |
|
|
'-d:installation directory:_files -/' \
|
178 |
|
|
'-n[area name]:area name' \
|
179 |
|
|
'*:::SCRAM project:_scram_projects_and_versions'
|
180 |
|
|
}
|
181 |
|
|
|
182 |
|
|
(( $+functions[_scram_install] )) ||
|
183 |
|
|
_scram_install()
|
184 |
|
|
{
|
185 |
|
|
_arguments -s \
|
186 |
|
|
'-h[show help for the install command]:print help for this command' \
|
187 |
|
|
'-f[force the installation]' \
|
188 |
|
|
'*:::optional project label and version'
|
189 |
|
|
}
|
190 |
|
|
|
191 |
|
|
(( $+functions[_scram_remove] )) ||
|
192 |
|
|
_scram_remove()
|
193 |
|
|
{
|
194 |
|
|
_arguments -s \
|
195 |
|
|
'-h[show help for the remove command]:print help for this command' \
|
196 |
|
|
'-f[force the installation]' \
|
197 |
|
|
'*:::SCRAM project:_scram_projects_and_versions'
|
198 |
|
|
}
|
199 |
|
|
|
200 |
|
|
(( $+functions[_scram_db] )) ||
|
201 |
|
|
_scram_db()
|
202 |
|
|
{
|
203 |
|
|
_arguments -s \
|
204 |
|
|
'-h[show help for the db command]:print help for this command' \
|
205 |
|
|
'-link[link to a SCRAM database]:linkdb:_files -g \*\*/project.lookup' \
|
206 |
|
|
'-unlink[remove linked SCRAM databases]:removedb:_scram_db_unlink' \
|
207 |
|
|
'-show[show linked SCRAM databases]'
|
208 |
|
|
}
|
209 |
|
|
|
210 |
|
|
(( $+functions[_scram_config] )) ||
|
211 |
|
|
_scram_config()
|
212 |
|
|
{
|
213 |
|
|
_arguments -s \
|
214 |
|
|
'-h[show help for the config command]:print help for this command' \
|
215 |
|
|
'-t[dump list of configured tools]' \
|
216 |
|
|
'-f[dump tools and project config]'
|
217 |
|
|
}
|
218 |
|
|
|
219 |
|
|
(( $+functions[_scram_urlget] )) ||
|
220 |
|
|
_scram_urlget()
|
221 |
|
|
{
|
222 |
|
|
_arguments -s \
|
223 |
|
|
'-h[show help for the urlget command]:print help for this command' \
|
224 |
|
|
'*::specify a scram document URL:( http:// file: cvs:// )'
|
225 |
|
|
}
|
226 |
|
|
|
227 |
|
|
|
228 |
|
|
|
229 |
|
|
############################## Auxiliary functions ##########################################
|
230 |
|
|
|
231 |
|
|
(( $+functions[_scram_tools_and_versions] )) ||
|
232 |
|
|
_scram_tools_and_versions()
|
233 |
|
|
{
|
234 |
|
|
local _scramtools expl
|
235 |
|
|
typeset -gA _scramtools
|
236 |
|
|
|
237 |
|
|
if (( ! $#_scramtools )); then
|
238 |
|
|
_scramtools=($(_call_program commands scram tool list | grep "^ " 2>&1))
|
239 |
|
|
fi
|
240 |
|
|
|
241 |
|
|
if (( $CURRENT == 2 )); then
|
242 |
|
|
if (( $#_scramtools )); then
|
243 |
|
|
local _version
|
244 |
|
|
_version=(${_scramtools[$words[1]]})
|
245 |
|
|
_wanted projectver expl 'select tool version' compadd -a _version
|
246 |
|
|
else
|
247 |
|
|
_message 'No tools: probably not in a project area'
|
248 |
|
|
fi
|
249 |
|
|
elif (( $CURRENT == 3 )); then
|
250 |
|
|
local _urls
|
251 |
|
|
_urls=(http:// cvs:// file:./)
|
252 |
|
|
_wanted urls expl 'ToolDoc URLs' compadd $_urls
|
253 |
|
|
else
|
254 |
|
|
if (( $#_scramtools )); then
|
255 |
|
|
_wanted tools expl 'configured tools' compadd ${(k)_scramtools}
|
256 |
|
|
else
|
257 |
|
|
_message 'No tools: probably not in a project area'
|
258 |
|
|
fi
|
259 |
|
|
fi
|
260 |
|
|
}
|
261 |
|
|
|
262 |
|
|
(( $+functions[_scram_db_unlink] )) ||
|
263 |
|
|
_scram_db_unlink()
|
264 |
|
|
{
|
265 |
|
|
local expl
|
266 |
|
|
|
267 |
|
|
_dbs=( $(_call_program dbs scram db -show | grep lookup | grep -v Current 2>/dev/null) )
|
268 |
|
|
|
269 |
|
|
if (( $#_dbs ));then
|
270 |
|
|
_wanted scramdb expl 'remove database' compadd -a _dbs
|
271 |
|
|
else
|
272 |
|
|
_message 'No databases linked'
|
273 |
|
|
fi
|
274 |
|
|
}
|
275 |
|
|
|
276 |
|
|
(( $+functions[_scram_graphing] )) ||
|
277 |
|
|
_scram_graphing()
|
278 |
|
|
{
|
279 |
|
|
local opts
|
280 |
|
|
opts=('package' 'global')
|
281 |
|
|
_wanted graph-mode expl 'graphing mode' compadd -P '=' $opts
|
282 |
|
|
}
|
283 |
|
|
|
284 |
|
|
(( $+functions[_scram_projects_and_versions] )) ||
|
285 |
|
|
_scram_projects_and_versions()
|
286 |
|
|
{
|
287 |
|
|
local expl _projects _versions
|
288 |
|
|
|
289 |
|
|
if (( $CURRENT == 2 )); then
|
290 |
|
|
_versions=( $(_call_program pversions scram l -c $words[1] | awk '{print $2}' |sort|uniq 2>/dev/null) )
|
291 |
|
|
_wanted projectver expl 'select project version' compadd -a _versions
|
292 |
|
|
else
|
293 |
|
|
_projects=( $(_call_program pversions scram l -c | awk '{print $1}' |sort|uniq 2>/dev/null) )
|
294 |
|
|
if (( $#_projects )); then
|
295 |
|
|
_wanted projects expl 'SCRAM project' compadd -a _projects
|
296 |
|
|
else
|
297 |
|
|
_message 'No installed projects'
|
298 |
|
|
fi
|
299 |
|
|
fi
|
300 |
|
|
}
|
301 |
|
|
|
302 |
|
|
|
303 |
|
|
##################################################### Main ####################################################
|
304 |
|
|
# Run the function with args passed down:
|
305 |
|
|
###############################################################################################################
|
306 |
|
|
_scram "$@"
|
307 |
|
|
|