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
|
This File: README for newfile
Introduction
------------
newfile is a small script that initializes new source files, scripts and
Makefile's based on skeleton files.
newfile selects the skeletion to use by examining the name under which it
is called: it strips the first three characters of its name and uses the
remainder to locate a .skel file. For example: if newfile is called as
newc, it will look for a file called c.skel.
The base location for the skeleton files is /usr/local/skeleton but can be
overriden by the NEWT_SKELETON_DIR environment variable.
Generic usage:
newfile filename [project]
name : name of file to be created. If it already exists you
will be asked if you want to overwrite it.
An extension is not required, it will be added automatically.
project: name of the project of which this new file will be
part.
The [project] argument can be used to provide default values for a number of
the substitutions newfile makes in the skeleton files. If it is given, newfile
will attempt to extract some variables from the projects file. The default
projects file is /usr/local/skeleton/projects but can be overriden by the
NEWT_PROJECT_FILE environment variable. See the file projects for more
information.
Skeletion files and variable substition
---------------------------------------
When newfile creates a new file based on a skeleton it will substitute certain
variables present in a skeleton file. They are:
@AUTHOR@
Name of the user creating the new file. This is the first entry of the
gecos field in /etc/passwd (, is regarded as a field separator).
Single quotes are escaped before substition.
If you are using NIS, the above will fail (unless you are root) and
newfile will use the result from whoami instead.
@DATE@
Date of creation;
@FILE@
Name of the file being created;
@DEFINE@
This is a special variable for use with header files. It is the name
of the file that is being created but in which the following characters
are replaced by an underscore: -. '`!#,:;+
The generated define is pre- and appended with an underscore as well.
Example: given foo-bar.h, the value of the @DEFINE@ variable will
be _foo_bar_h_
@PROJECTNAME@
Name of the project for which the new file is created. This is equal
to the project given on the command line.
Default value: "NONE"
@PROJECT@
A description of the project. It is the second field in the entry for
a project in the projects file.
Default value: "This file is part of no particular project."
@APPTYPE@
Application type. I use this to generate the correct license text in
all new files. It is the third field in the entry for a project in the
projects file.
Default value: "program"
@LICTYPE@
License type. Also used to generate the correct license text in all
new files. It is the fourth field in the entry for a project in the
projects file.
No default value.
Adding support for other file types
-----------------------------------
- create a new skeleton file. Add the appropriate variables you wish to see
substituted.
- create an appropriate link to newfile.
That's all there is to it.
Default skeleton files
----------------------
c.skel:
skeleton file for a C source file;
Program name: newc
h.skel:
skeleton file for a C header file;
Program name: newh
sh.skel
skeleton file for a /bin/sh shell script;
Program name: newsh
topmake.skel
skeleton file for a toplevel makefile;
Program name: newtopmake
libmake.skel
skeleton file for a library makefile;
Program name: newlibmake
progmake.skel
skeleton file for a program makefile;
Program name: newprogmake
Feel free to use it.
Koen D'Hondt <ripley@xs4all.nl>
|