Name

nstnewscript — Stubs in the start of a new script into a NST development system.

Synopsis

nstnewscript -n TEXT | --name TEXT [ -a TEXT | --author TEXT ] [ -r FILENAME | --root FILENAME ] [ -c FILENAME | --config FILENAME ] [ -h [true]|false | --help [true]|false ] [ -H [true]|false | --help-long [true]|false ] [ -v [true]|false | --verbose [true]|false ] [ --version [true]|false ]

Description

The nstnewscript is used by NST developers when they want to create a new script for the NST distribution. Scripts created in this manner will help produce consistency.

Each time you run this script, it creates the following (but only if they don't exist):

src/scripts/NAME

A dedicated directory for source files to associate with the new script.

src/scripts/NAME/makefile

A simple makefile used to build the new script (and its documentation) from the source files.

src/scripts/NAME/NAME.nstscript

A XML file which defines the legal command line arguments which the script accepts. You will want to edit this file in emacs to add and modify the command line argument options.

src/scripts/NAME/NAME.sh

The body of the new script. This is where you place the "meat" of script.

src/scripts/NAME/NAME.docbook

A template DocBook file used to document your script. You will want to update this file after you finish your script.

src/scripts/NAME/.cvsignore

This file tells CVS what files are generated during the build process. It will prevent the question marks from appearing when you commit or update your CVS area.

Note

The above directory and files will ALL need to be added and committed to CVS in order to make your script a permanent addition to the NST source tree.

There are several conventions in using nstnewscript to create new scripts:

  • You can only run the script if you are within the NST development directory.

  • Only rudimentary checks are made on command line options (you will probably need to add additional checks).

  • If your script has a required command line option, you should set its default value to REQUIRED.

  • If you create a simple script (just the standard script and help file), and you want it to be included in the NST distribution, you should add the name of your script to the NSTSCRIPT_LIST array found in src/packages/system/nstscripts.sh.

  • There are many functions which are useful in creating scripts. These common functions are housed in the src/include/functions directory. To add these functions to your script, you update the INCLUDES setting in your makefile. For example, the following would add the functions found in version.bash and long_help.bash:

    INCLUDES=version.bash long_help.bash
    

    Note

    There are dependencies - so including one file may require another. If you use INCLUDES=$(STANDARD_SCRIPT_INCLUDES), it will put in the standard functions used by most NST scripts and reduce the chance of you omitting a dependency.

Options

The following command line options are available:

-n TEXT | --name TEXT

This option specifies the name of the new script to create. This option is required. If omitted, an error will be shown along with the short usage information.

[-a TEXT] | [--author TEXT]

By default, we assume that the USER environment variable is set to the ID of the author creating the script. You can use this option to force the author ID to a specific value (if you are logged in as someone else).

[-r FILENAME] | [--root FILENAME]

In order to create the necessary files, we need to know where the top most directory of the source code is located on the system. If you omit this argument, we will attempt to find it by first checking the current directory and then recursively checking the parent directories. You only need to specify this command line argument if you run the script from a directory outside of the source code.

[-c FILENAME] | [--config FILENAME]

By default, the nstnewscript will attempt to load configuration information from both /etc/nst.nstnewscript.conf and ${HOME}/.nst.nstnewscript.conf (where the values in the latter file take precedence). If the files are not found, then all required parameters must be specified on the command line. You can specify --config FILE to load a configuration file other than ${HOME}/.nst.nstnewscript.conf. You may specify --config no to disable the loading of any configuration. You may specify --config load if you want the script to exit in error if ${HOME}/.nst.nstnewscript.conf is not found. You may specify --config save to save the options specified as ${HOME}/.nst.nstnewscript.conf. You may specify --config show to see what the current command line arguments (or default values) would look like if saved in a configuration file.

[-h [true]|false] | [--help [true]|false]

When this option is specified, nstnewscript will display a short one line description of nstnewscript, followed by a short description of each of the supported command line options. After displaying this information nstnewscript will terminate.

[-H [true]|false] | [--help-long [true]|false]

This option will attempt to pull up additional nstnewscript documentation within a text based web browser. You can force which browser we use setting the environment variable TEXTBROWSER, otherwise, we will search for some common ones.

[-v [true]|false] | [--verbose [true]|false]

When you set this option to true, nstnewscript will produce additional output. This is typically used for diagnostic purposes to help track down when things go wrong.

[--version [true]|false]

If this option is specified, the version number of the script is displayed.