ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/SCRAM/doc/tex/manual/Appendix.tex
Revision: 1.2
Committed: Mon Nov 7 14:30:19 2005 UTC (19 years, 6 months ago) by sashby
Content type: application/x-tex
Branch: MAIN
Changes since 1.1: +6 -7 lines
Log Message:
Update to docs.

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