A NIC template is a collection of files representing a basic project, before any user customizations have been added.
texttext is required to be part of the directive and is not to be substituted with any other values....... may be optionally repeated with the specified delimiter.NIC/control)Each NIC template requires a control file. The control file contains basic static information about the template.
name "name"prompt variable "prompt text" "default value"
~/.nicrc.
constrain "path" to constraint
ignore built-in variable
USERPACKAGENAMEpackage!package, can be used to create files only when the project is not being packaged.package constraint to avoid creating unnecessary control files.link_theoslink_theos in the user's ~/.nicrc.theos/ symlinks.NIC/control
name "Awesome Template"
constrain "control" to package
prompt PIES "Number of Pies to create" "10"
NIC/control.pl)The package control script is an optional addition to the NIC format.
Control scripts are written in Perl and have access to the current template.
There are various objects available to you via the NIC scripting interface.
print $datawarn $warningerror $errorexit $status_code1 will abort building the template.
prompt($prompt_text , {default => $default_value})NICThe NIC object represents the current template.
NIC->nameNIC->variablesNIC->variable($name)NIC->variable("NAME") = "Value";
NIC->prompt($variable, $prompt_text , {default => $default_value})NIC->prompt(...) will return the user's response, and will not store it in the template.prompt(...) and NIC->prompt(...) is that the user is given a chance to override the prompt variable with his or her ~/.nicrc.
NIC->setConstraint($constraint)NIC->clearConstraint($constraint)NIC->lookup($name)undef on failure.
NIC->mkfile($name , $mode)NIC->mkdir($name , $mode)NIC->symlink($target, $destination)$target is expected to be an object acquired via NIC->lookup, NIC->mkdir, NIC->mkfile, or NIC->symlink.$target can also be a string.NICTypeNICType objects are the embodiment of template content. Each file, directory or symbolic link is represented by an instance of a NICType subclass. NICType objects share a few common propeties.
$nictype->name$nictype->mode0644 for files and 0755 for directories.
$nictype->constraints$nictype->constrain($constraint)NIC/control's constrain ....
File <- NICTypeRepresents a file in the template.
$file->dataDirectory <- NICTypeRepresents a directory in the template.
Contains no additional methods.
Symlink <- NICTypeRepresents a symbolic link in the template.
$symlink->targetNICType object or a string.
NIC/control.pl
# Retrieve the package name as specified by the user.
my $packageName = NIC->variable("PACKAGENAME");
my $packageDirectory = $packageName;
# Transform the package name into a package directory, replacing . with / (s!old!new!g acts as a search and replace).
$packageDirectory =~ s!\.!/!g;
# Create a new directory entry with the name we just transformed.
my $directory = NIC->mkdir($packageDirectory);
# Look up the file "main.m" and set its name to include the new path.
NIC->lookup("main.m")->name = $directory->name . "/main.m";