1#!/bin/tcsh
2
3### Script to put all afni program -help outputs
4###   into one big PostScript file AFNI.help.ps
5###   and thence into AFNI.help.pdf
6### Uses the mpage utility for formatting,
7###   and then gs utility for conversion to PDF
8
9setenv AFNI_ENVIRON_WARNINGS NO
10
11# make the list of programs to run
12
13find ~/abin -depth 1 -name '[13]d*' > qhelp.txt
14find ~/abin -depth 1 -name '*.py'  >> qhelp.txt
15find ~/abin -depth 1 -name '@*'    |  grep -v '@Install_' | grep -v 'OLD' >> qhelp.txt
16
17# cast out duplicates
18
19set plist = ( `sort qhelp.txt | uniq` )
20
21if( -f AFNI.help.txt ) \rm AFNI.help.txt
22touch AFNI.help.txt
23
24foreach fred ( $plist )
25
26# not executable?
27
28  if( ! -x $fred ) continue
29
30# skip .R programs
31  set bbb = `basename $fred`
32  set ccc = `basename $bbb .R`
33  if( $bbb != $ccc ) continue
34
35  if( -f qhelp.txt ) \rm qhelp.txt
36
37  echo "++ running $fred -help"
38# make a help text file
39  $fred -help >& qhelp.txt
40
41# skip it if is too short
42  set nn = `wc -l < qhelp.txt`
43  if( $nn < 20 ) continue
44
45# put it into a big text file, along with a page feed
46  cat qhelp.txt >> AFNI.help.txt
47  echo ''     >> AFNI.help.txt
48
49  echo " + `wc -l < AFNI.help.txt`" " lines of help so far"
50
51end
52
53# convert big text file to the PostScript output
54mpage -1H AFNI.help.txt > AFNI.help.ps
55
56# convert to PDF
57gs -sDEVICE=pdfwrite -sOutputFile=AFNI.help.pdf -dNOPAUSE -q - < AFNI.help.ps
58
59# take out the trash
60if( -f qhelp.txt ) \rm qhelp.txt
61
62exit 0
63