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>
