File: README

package info (click to toggle)
template-new 1.2.0-2
  • links: PTS
  • area: main
  • in suites: woody
  • size: 844 kB
  • ctags: 262
  • sloc: sh: 7,750; ansic: 2,127; makefile: 96
file content (234 lines) | stat: -rw-r--r-- 7,298 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
README

W. Michael Petullo
     _________________________________________________________________
   
COPYRIGHT

   Copyright  1999 W. Michael Petullo
   
   <[1]new@flyn.org>
   All rights reserved.
   
   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2 of the License, or (at
   your option) any later version.
   
   This program is distributed in the hope that it will be useful, but
   WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
   General Public License for more details.
   
   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
   USA
     _________________________________________________________________
   
OVERVIEW

   New is a template system, especially useful in conjunction with a
   simple text editor such as vi. The user maintains templates which may
   contain format strings. At run time, new replaces the format strings
   in a template with appropriate values to create a new file.
   
   For example, given the following template:
//   FILE: %(FILE)
// AUTHOR: %(FULLNAME)
//   DATE: %(DATE)
   
// Copyright (c) 1999 %(FULLNAME) %(EMAIL)
// All rights reserved.

   new will create:
//   FILE: foo.cpp
// AUTHOR: W. Michael Petullo
//   DATE: 11 September 1999
   
// Copyright (c) 1999 W. Michael Petullo new@flyn.org
// All rights reserved.

   on my computer.
   
   The program understands plaintext or gzip template files.
   
   Building new also creates a shared library, libtemplate, which allows
   the programmer access to new's functionality.
     _________________________________________________________________
   
BUILDING

   To build, cross your fingers and try...
    1. ./configure
    2. make
    3. make install
       
   Read the ``INSTALL'' file for generic detailed information on
   installing this program.
     _________________________________________________________________
   
NASTY DETAILS

   New first looks for templates in ~/.new/templates. Second, new looks
   for templates in <datadir>/new/template, where datadir is defined by
   autoconf. This directory is usually /usr/local/share or /usr/share.
   
   The templates directory contains several subdirectories matching
   filename extensions. This may include directories such as html, cpp,
   c, and tex. Within each subdirectory are the actual template files.
   The template file named default is the default template used for the
   filename extension. Other templates can be used by specifying their
   filename to new on the command line (see new(1)).
   
   Certain types of files generally don't have extensions. In this case,
   new looks for a template directory with the same name as the file
   being created. This is useful when using templates to create files
   with names such as Makefile and README.
   
   When filling a format pattern, new knows the value for the following
   format patterns:
   
   DATE
          Today's date.
          
   FILE
          The name of the file being created.
          
   FULLNAME
          The user's full name (from GECOS field).
          
   FIRSTNAME
          The user's first name (from GECOS field).
          
   MIDDLENAME
          The user's middle name (from GECOS field).
          
   LASTNAME
          The user's last name (from GECOS field).
          
   EMPTY_STR
          The empty string.
          
   In addition, any environment variable can be used as a format pattern.
   An alternate string to be used in the case of an environment variable
   being undefined can be specified as follows:
   
   %(UNDEFINED:foo)
   
   This will be replaced with ``foo'' in the created file if UNDEFINED is
   not a part of one's environment.
   
   A format pattern can also be acted on by a modifier. The following
   will print the value of FOO in capital letters:
   
   %(upper FOO)
   
   The following modifiers are currently available:
   
   upper
          Convert to upper case.
          
   lower
          Convert to lower case.
          
   basename
          Convert to the basename of a filename.
          
   before="str"
          Append the string str before.
          
   after="str"
          Append the string str after.
          
   fn
          Tag a " ()" on the end.
          
   c_delim
          Print enveloped in a C style deliminator, ie: /* == foo == */.
          
   cpp_delim
          Print enveloped in a C++ style deliminator, ie: // == foo.
          
   sh_delim
          Print enveloped in a shell script style deliminator, ie: # ==
          foo.
          
   tex_delim
          Print eveloped in a LaTeX style deliminator, ie: % == foo.
          
   #
          A comment, this will not appear in destination file %(#
          Comment.)
          
   Several modifiers can act within one format string as illustrated:
   
   %(basename upper FOO)
   
   Modifiers use a stack to be applied. The first modifier to be applied
   is the one farthest to the right. The last to be applied it the one
   farthest to the left.
   
   One special modifier, template, exists which behaves differently than
   the others. The following example demonstrates this behavior:
   
   %(template /path/to/file)
   
   This example reads /path/to/file and treats it as a format string.
   This format string is filled and inserted into the output file.
   
   The modifier file is similar to template but does not cause the path
   to be filled before being inserted.
     _________________________________________________________________
   
PROVIDED TEMPLATES

   I have included in the new distribution the templates that I use.
   While you may not find them directly useful, they serve as good
   examples of how to write new templates.
   
   A few of my templates make references to special environment
   variables, which I define in my login scripts:
   
   .in (spec), .spec (default):
   
   RPM_BUILD_ROOT
          Directory to be used for RPM's BuildRoot (/ if undefined).
          
   URL
          URL to be used for RPM's URL (FIXME if undefined).
          
   .am (default):
   
   WEB_DIR
          Directory for publishing to the web; used by make publish
          clause (/tmp if undefined).
          
   Makefile (rpm), am (default):
   
   RPM_TOP_DIR
          RPM's topdir (/usr/src/redhat or as specified by %_topdir in
          .rpmmacros) (/usr/src/redhat if undefined).
          
   .tex (letter):
   
   ADDRESS_1
          Line one of sender's mailing address (for return address)
          (FIXME: return address line one if undefined).
          
   ADDRESS_2
          Line two of sender's mailing address (FIXME: return address
          line two if undefined).
          
   CITY
          City the sender lives in (FIXME: city if undefined).
          
   STATE
          State the sender lives in (FIXME: state if undefined).
          
   ZIP_CODEi
          Zip code the sender lives in (FIXME zip if undefined).

References

   1. mailto:new@flyn.org