ControlTier > core
 

create-type

Command Reference

Description

Create a new type source directory and initial type.xml.

New types can be added to the project using the create-type command. This seeds the new type from a set of boiler plate files, and creates skelaton module structure.

The module structure includes a set of standard files (like type.xml) and subdirectories as shown below:

  • TypeX/
    • type.xml ;# type definition file
    • commands/
      • commandA.xml ;# implementation for commandA
      • commandB.xml ;# implementation for commandB
    • objects/ ;# holds optional instance data files
    • templates/ ;# holds optional template files
    • scripts/ ;# holds optional script files for auto-generated commands

Type definition falls into two areas:

  1. Commands: Typically, the primary aspect of the type definiton is the declaration of commands. The process begins by defining a new new command element in the type.xml. Second, a corresponding command implementation is developed. As noted elsewhere, this second step can be left to Workbench if the command is shellscript or workflow type.
  2. Schema: The initial type.xml created by create-type includes the basics, declaring the supertype and some boiler plate elements. One might also like to define Settings subtypes and attributes to build up a data model useful to your commands.

Using existing scripts for commands definitions

You can use a set of existing scripts to generate initial commands for the new module. Specify the -initialize -scriptdir /path/to/scripts options. All scripts in the scriptdir will be copied to the new module source, and a new command defined with the same name as the script file.

See the -scriptdir option.

static: This command can be run outside of an object context.

Usage

ctl -m ProjectBuilder -c create-type [-basedir <>] [-description <>] [-initialize] [-scriptdir <>] [-supertype <>] [-type <>]

Options

Option Description Type Default
basedir the base modules directory where this type will be created

If this option is not specified on the commandline or via the entity.attribute.basedir attribute, the user will be prompted interactively to enter a value.

string ${entity.attribute.basedir}
description type description

If this option is not specified on the commandline, the user will be prompted interactively to enter a value.

string
initialize If true, initialize some commands from scripts in the scriptdir. boolean
scriptdir Directory of scripts to use as commands. Used with initialize option.

When -initialize is set, use all script files found in this directory as commands in the new type.

Scripts are matched with the following file extensions:

  • sh: Shell scripts, which will be executed with the sh command.
  • bat: Windows batch scripts, which will be executed with the cmd.exe command on Windows.
  • xml: Ant scripts, which will be executed with Ant.

Each found script will have a corresponding command defined in the type. For example, a script named avertDisaster.sh will be defined as a command named avertDisaster, and will call the script. The script file itself will be copied to the scripts/ directory of the Module directory, and thus will be included in the Module archive jar when it is built with the build-type command.

Each command defined this way will have an argline option, allowing commandline parameters to be passed to the script.

string
supertype super type name

If this option is not specified on the commandline, the user will be prompted interactively to enter a value.

string
type type name

If this option is not specified on the commandline, the user will be prompted interactively to enter a value.

string

Examples

Example: Create a type called MyBuilder, a subtype of Builder:

ctl -p project -m ProjectBuilder -c create-type --\
	  -supertype Builder -type MyBuilder
	  

The create-type command will work interactively if no arguments are given for the basedir and targetdir options.

Example: Create a type called myapputil, a subtype of Managed-Entity, and use a set of existing scripts as commands in the module:

ctl -p project -m ProjectBuilder -c create-type --\
          -supertype Managed-Entity -type myapputil -initialize -scriptdir /path/to/scripts
	  

Each script in /path/to/scripts will be used to create a new command in the module with the same name as the script.