ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/doc/tex/manual/Appendix.tex
Revision: 1.1
Committed: Wed Nov 2 16:24:18 2005 UTC (19 years, 6 months ago) by sashby
Content type: application/x-tex
Branch: MAIN
CVS Tags: V1_0_2_p1
Log Message:
Commit first version of updated manual.

File Contents

# User Rev Content
1 sashby 1.1 %%____________________________________________________________________
2     %% File: Appendix.tex
3     %%____________________________________________________________________
4     %%
5     %% Author: Shaun ASHBY <Shaun.Ashby@cern.ch>
6     %% Update: 2005-11-02 17:11:52+0100
7     %% Revision: $Id$
8     %%
9     %% Copyright: 2005 (C) Shaun ASHBY
10     %%
11     %%--------------------------------------------------------------------
12     \chapter{Appendix}\label{ch:appendix}
13    
14     \section{\scram\ Function for the ZSH Completion System}
15    
16     For all users of \texttt{zsh}, a completion function can be defined
17     for \scram\ so that command and option completion is possible. The
18     completion function below should be saved as \texttt{\_scram}
19     somewhere in a user directory. For it to be found by \texttt{zsh}, a
20     path variable called \texttt{fpath} must be defined in
21     \texttt{.zshenv} or \texttt{.zshrc} to include the
22     system-wide \texttt{fpath} and the user one. For example, if the
23     completion function was located in a directory called
24     \texttt{compfunc} in the user home directory, the following statement
25     \begin{verbatim}
26     fpath=(\$fpath \$HOME/compfunc)
27     \end{verbatim}
28     must be made in the \texttt{zsh} startup files. Note that you may also
29     need to activate the completion system by adding
30     \begin{verbatim}
31     autoload -U compinit
32     compinit
33     \end{verbatim}
34     to your \texttt{.zshrc}.
35    
36     \ni The completion function is included below in full but can be copied from the
37     \texttt{scripts} directory in the \scram\ source tree.
38    
39     \paragraph{\scram\ completion function}
40     \small{
41     \begin{verbatim}
42     #compdef scram
43    
44     _scram()
45     {
46     _arguments -s \
47     '-h[show help]' \
48     '-v[version]' \
49     '-d[debug mode]' \
50     '-n[no return]' \
51     '-arch:supported architectures:(rh73_gcc323 slc3_ia32_gcc323)' \
52     '*::scram command:_scram_command'
53     }
54    
55     (( $+functions[_scram_command] )) ||
56     _scram_command ()
57     {
58     local _scram_cmds
59     _scram_cmds=(version arch setup runtime build list project tool install remove db config urlget)
60    
61     if (( CURRENT == 1 )); then
62     _tags _scram_cmds && { compadd "$@" -a _scram_cmds }
63     else
64     local curcontext="$curcontext"
65     cmd="$words[1]"
66     if (( $#cmd )); then
67     curcontext="${curcontext%:*:*}:scram-${cmd}:"
68     _scram_$cmd
69     else
70     _message "unknown scram command: $words[1]"
71     fi
72     fi
73     }
74    
75     (( $+functions[_scram_version] )) ||
76     _scram_version()
77     {
78     _arguments -s \
79     '-h[show help for the version command]:print help for this command' \
80     '-c[show CVS parameters for SCRAM downloads]' \
81     '-i[show CVS commit information]' \
82     '*::specify a version to download:(V1_0_0 V1_0_1)'
83     }
84    
85     (( $+functions[_scram_arch] )) ||
86     _scram_arch()
87     {
88     _arguments -s \
89     '-h[show help for the arch command]:print help for this command'
90     }
91    
92     (( $+functions[_scram_setup] )) ||
93     _scram_setup()
94     {
95     # scram setup [-i] [-f tools.conf] [toolname] [[version] [url]]
96     _arguments -s \
97     - set1 \
98     '-h[show help for the setup command]:print help for this command' \
99     - set2 \
100     '-i[interactive setup mode]' \
101     '-f[file for tool default settings]:tool config defaults:_files -g \*.conf' \
102     "*::tool list:_scram_tools_and_versions"
103     }
104    
105     (( $+functions[_scram_runtime] )) ||
106     _scram_runtime()
107     {
108     _arguments -s \
109     - set1 \
110     '-h[show help for the runtime command]:print help for this command' \
111     - set2 \
112     '(-c -w)-s[Bourne-like shell environment]' \
113     '(-s -w)-c[TCSH shell environment]' \
114     '(-c -s)-w[Win32 shell environent]' \
115     '-d[dump the current environment]:filename' \
116     - set3 \
117     '(-c -w)-s[Bourne-like shell environment]' \
118     '(-s -w)-c[TCSH shell environment]' \
119     '(-c -s)-w[Win32 shell environent]' \
120     '-f:read an environment from a file:_files -g \*.env'
121     }
122    
123     (( $+functions[_scram_tool] )) ||
124     _scram_tool()
125     {
126     local expl
127     _arguments -s \
128     '-h[show help for the tool command]:print help for this command'
129    
130     if (( $CURRENT == 2 )); then
131     local tooltags
132     tooltags=(list info tag remove template)
133     _wanted cmds expl 'tool sub-command' compadd -a tooltags
134     elif (( $CURRENT == 3 )); then
135     local _scramtools
136     typeset -gA _scramtools
137    
138     if (( ! $#_scramtools )); then
139     _scramtools=($(_call_program commands scram tool list | grep "^ " 2>&1))
140     fi
141    
142     case "$words[2]" in
143     list)
144     _message 'list configured tools'
145     ;;
146     info|remove|tag)
147     if (( $#_scramtools )); then
148     _wanted tools expl 'list of configured tools' compadd ${(k)_scramtools}
149     else
150     _message 'No tools: probably not in a project area'
151     fi
152     ;;
153     template)
154     local tmpltypes
155     tmpltypes=(compiler basic)
156     _wanted tmpl expl 'template type to download' compadd -a tmpltypes
157     ;;
158     esac
159     elif (( $CURRENT == 4 )); then
160     local _toolstags
161    
162     if (( ! $#_toolstags )); then
163     _toolstags=($(_call_program commands scram tool tag $words[3] 2>&1))
164     fi
165     _wanted ttags expl "tags defined for $words[3]" compadd -a _toolstags
166     fi
167     }
168    
169     (( $+functions[_scram_build] )) ||
170     _scram_build()
171     {
172     local makeopts
173     makeopts=(
174     '-n[print the commands that would be executed but do not run them]'
175     '--printdir[print the working directory before and after entering it]'
176     '--printdb[print the data base of rules after scanning makefiles, then build as normal]'
177     '-j[the number of processes to run simultaneously]'
178     '-k[continue for as long as possible after an error]'
179     '-s[do not print any output]'
180     '-d[run gmake in debug mode]'
181     )
182    
183     _arguments -s \
184     '-h[show help for the build command]:print help for this command' \
185     '-v[show compilation command]' \
186     '-r[reset cache]' \
187     '-f[skip cache scan]' \
188     '-t[dry run]' \
189     '-w-[graphing mode type]:graphing mode:_scram_graphing' \
190     "$makeopts[@]" \
191     '*::targets:(shared module python bin app)'
192     }
193    
194     (( $+functions[_scram_list] )) ||
195     _scram_list()
196     {
197     _arguments -s \
198     '-h[show help for the list command]:print help for this command' \
199     '-c[show a compact list]' \
200     '-o[use old-style listing (i.e. all projects)]' \
201     '*::SCRAM project:_scram_projects_and_versions'
202     }
203    
204     (( $+functions[_scram_project] )) ||
205     _scram_project()
206     {
207     # scram project [-t] [-d <area>] [-n <dir>] [-f <tools.conf>] <projecturl> [<projectversion>]
208     _arguments \
209     - set1 \
210     '-h[show help for the project command]:print help for this command' \
211     - set2 \
212     '-t[download project templates]:download project templates' \
213     - set3 \
214     '-f:file for tool defaults:_files -g \*.conf' \
215     '-b[bootstrap files]:bootstrap:_files -g conf\*/boot\*' \
216     - set4 \
217     '-d:installation directory:_files -/' \
218     '-n[area name]:area name' \
219     '*:::SCRAM project:_scram_projects_and_versions'
220     }
221    
222     (( $+functions[_scram_install] )) ||
223     _scram_install()
224     {
225     _arguments -s \
226     '-h[show help for the install command]:print help for this command' \
227     '-f[force the installation]' \
228     '*:::optional project label and version'
229     }
230    
231     (( $+functions[_scram_remove] )) ||
232     _scram_remove()
233     {
234     _arguments -s \
235     '-h[show help for the remove command]:print help for this command' \
236     '-f[force the installation]' \
237     '*:::SCRAM project:_scram_projects_and_versions'
238     }
239    
240     (( $+functions[_scram_db] )) ||
241     _scram_db()
242     {
243     _arguments -s \
244     '-h[show help for the db command]:print help for this command' \
245     '-link[link to a SCRAM database]:linkdb:_files -g \*\*/project.lookup' \
246     '-unlink[remove linked SCRAM databases]:removedb:_scram_db_unlink' \
247     '-show[show linked SCRAM databases]'
248     }
249    
250     (( $+functions[_scram_config] )) ||
251     _scram_config()
252     {
253     _arguments -s \
254     '-h[show help for the config command]:print help for this command' \
255     '-t[dump list of configured tools]' \
256     '-f[dump tools and project config]'
257     }
258    
259     (( $+functions[_scram_urlget] )) ||
260     _scram_urlget()
261     {
262     _arguments -s \
263     '-h[show help for the urlget command]:print help for this command' \
264     '*::specify a scram document URL:( http:// file: cvs:// )'
265     }
266    
267    
268    
269     ############################## Auxiliary functions ##########################################
270    
271     (( $+functions[_scram_tools_and_versions] )) ||
272     _scram_tools_and_versions()
273     {
274     local _scramtools expl
275     typeset -gA _scramtools
276    
277     if (( ! $#_scramtools )); then
278     _scramtools=($(_call_program commands scram tool list | grep "^ " 2>&1))
279     fi
280    
281     if (( $CURRENT == 2 )); then
282     if (( $#_scramtools )); then
283     local _version
284     _version=(${_scramtools[$words[1]]})
285     _wanted projectver expl 'select tool version' compadd -a _version
286     else
287     _message 'No tools: probably not in a project area'
288     fi
289     elif (( $CURRENT == 3 )); then
290     local _urls
291     _urls=(http:// cvs:// file:./)
292     _wanted urls expl 'ToolDoc URLs' compadd $_urls
293     else
294     if (( $#_scramtools )); then
295     _wanted tools expl 'configured tools' compadd ${(k)_scramtools}
296     else
297     _message 'No tools: probably not in a project area'
298     fi
299     fi
300     }
301    
302     (( $+functions[_scram_db_unlink] )) ||
303     _scram_db_unlink()
304     {
305     local expl
306    
307     _dbs=( $(_call_program dbs scram db -show | grep lookup | grep -v Current 2>/dev/null) )
308    
309     if (( $#_dbs ));then
310     _wanted scramdb expl 'remove database' compadd -a _dbs
311     else
312     _message 'No databases linked'
313     fi
314     }
315    
316     (( $+functions[_scram_graphing] )) ||
317     _scram_graphing()
318     {
319     local opts
320     opts=('package' 'global')
321     _wanted graph-mode expl 'graphing mode' compadd -P '=' $opts
322     }
323    
324     (( $+functions[_scram_projects_and_versions] )) ||
325     _scram_projects_and_versions()
326     {
327     local expl _projects _versions
328    
329     if (( $CURRENT == 2 )); then
330     _versions=( $(_call_program pversions scram l -c $words[1] | awk '{print $2}' |sort|uniq 2>/dev/null) )
331     _wanted projectver expl 'select project version' compadd -a _versions
332     else
333     _projects=( $(_call_program pversions scram l -c | awk '{print $1}' |sort|uniq 2>/dev/null) )
334     if (( $#_projects )); then
335     _wanted projects expl 'SCRAM project' compadd -a _projects
336     else
337     _message 'No installed projects'
338     fi
339     fi
340     }
341    
342    
343     ##################################################### Main ####################################################
344     # Run the function with args passed down:
345     ###############################################################################################################
346     _scram "$@"
347    
348    
349     \end{verbatim}}\normalsize
350    
351     %%% Local Variables:
352     %%% mode: latex
353     %%% TeX-master: "SCRAM-manual"
354     %%% End:
355    
356     %%____________________________________________________________________
357     %% End of Appendix.tex
358     %%____________________________________________________________________
359     %%