ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/scripts/_scram
Revision: 1.3
Committed: Mon Sep 11 13:39:48 2006 UTC (18 years, 8 months ago) by sashby
Branch: MAIN
CVS Tags: V1_0_3-p4, forV1_1_0, v103_xml_071106, V1_0_3-p3, V1_0_3-p2, V110p3, V110p2, V110p1, V1_0_3-p1, V1_0_3
Branch point for: v200branch, v103_with_xml
Changes since 1.2: +4 -4 lines
Log Message:
*** empty log message ***

File Contents

# User Rev Content
1 sashby 1.3 #compdef scram scramv1
2     # $Id: _scram,v 1.2.2.2 2006/09/04 15:51:09 sashby Exp $
3 sashby 1.1 #
4     _scram()
5     {
6     _arguments -s \
7     '-h[show help]' \
8     '-v[version]' \
9     '-d[debug mode]' \
10     '-n[no return]' \
11 sashby 1.3 '-arch:supported architectures:(slc3_ia32_gcc323 slc3_ia32_gcc323_dbg slc4_ia32_gcc345 slc4_ia32_gcc345_dbg osx104_ia32_gcc40)' \
12 sashby 1.1 '*::scram command:_scram_command'
13     }
14    
15     (( $+functions[_scram_command] )) ||
16     _scram_command ()
17     {
18     local _scram_cmds
19 sashby 1.2 _scram_cmds=(version arch setup runtime build list project tool install remove db config urlget gui xmlmigrate)
20 sashby 1.1
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 sashby 1.3 '*::specify a version to download:(V1_0_1 V1_0_2 V1_0_3)'
43 sashby 1.1 }
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 sashby 1.2 '--xmlb[Read XML BuildFiles]' \
151 sashby 1.1 "$makeopts[@]" \
152 sashby 1.2 '*::targets:(release release-build shared bin test)'
153 sashby 1.1 }
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 sashby 1.2 (( $+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 sashby 1.1
238 sashby 1.2 (( $+functions[_scram_xmlmigrate] )) ||
239     _scram_xmlmigrate()
240     {
241     _arguments -s \
242     '-h[show help for the xmlmigrate command]:print help for this command'
243     }
244 sashby 1.1
245 sashby 1.2 ############# Auxiliary functions ##############
246 sashby 1.1
247     (( $+functions[_scram_tools_and_versions] )) ||
248     _scram_tools_and_versions()
249     {
250     local _scramtools expl
251     typeset -gA _scramtools
252    
253     if (( ! $#_scramtools )); then
254     _scramtools=($(_call_program commands scram tool list | grep "^ " 2>&1))
255     fi
256    
257     if (( $CURRENT == 2 )); then
258     if (( $#_scramtools )); then
259     local _version
260     _version=(${_scramtools[$words[1]]})
261     _wanted projectver expl 'select tool version' compadd -a _version
262     else
263     _message 'No tools: probably not in a project area'
264     fi
265     elif (( $CURRENT == 3 )); then
266     local _urls
267     _urls=(http:// cvs:// file:./)
268     _wanted urls expl 'ToolDoc URLs' compadd $_urls
269     else
270     if (( $#_scramtools )); then
271     _wanted tools expl 'configured tools' compadd ${(k)_scramtools}
272     else
273     _message 'No tools: probably not in a project area'
274     fi
275     fi
276     }
277    
278     (( $+functions[_scram_db_unlink] )) ||
279     _scram_db_unlink()
280     {
281     local expl
282    
283     _dbs=( $(_call_program dbs scram db -show | grep lookup | grep -v Current 2>/dev/null) )
284    
285     if (( $#_dbs ));then
286     _wanted scramdb expl 'remove database' compadd -a _dbs
287     else
288     _message 'No databases linked'
289     fi
290     }
291    
292     (( $+functions[_scram_graphing] )) ||
293     _scram_graphing()
294     {
295     local opts
296     opts=('package' 'global')
297     _wanted graph-mode expl 'graphing mode' compadd -P '=' $opts
298     }
299    
300     (( $+functions[_scram_projects_and_versions] )) ||
301     _scram_projects_and_versions()
302     {
303     local expl _projects _versions
304    
305     if (( $CURRENT == 2 )); then
306     _versions=( $(_call_program pversions scram l -c $words[1] | awk '{print $2}' |sort|uniq 2>/dev/null) )
307     _wanted projectver expl 'select project version' compadd -a _versions
308     else
309     _projects=( $(_call_program pversions scram l -c | awk '{print $1}' |sort|uniq 2>/dev/null) )
310     if (( $#_projects )); then
311     _wanted projects expl 'SCRAM project' compadd -a _projects
312     else
313     _message 'No installed projects'
314     fi
315     fi
316     }
317    
318    
319 sashby 1.2 ################ Main ###################
320 sashby 1.1 # Run the function with args passed down:
321 sashby 1.2 #########################################
322 sashby 1.1 _scram "$@"
323