Titanium 3.X
Alloy Command-Line Interface Reference

Alloy Command-Line Interface Reference

The Alloy Command-Line Interface (CLI) is a command-line tool for managing and building Alloy projects.

New

Creates a new Alloy project.

alloy new [<project_path>] [<project_template>] [--force] [--no-colors]

Options

Description

<project_path>

Path to a skeleton Titanium project, otherwise the current working directory is used.

<project_template>

Selects the template. Choose between default for a single pane application or two_tabbed or a tabbed application. Defaults to default.

-f, --force

Forces the command to execute.

-n, --no-colors

Disables color output.

Generate

Creates skeleton Alloy components.

alloy generate <component> [--outputPath <output_path>] [--platform <platform>] [--force] [--no-colors] 

Options

Description

<component>

Format is component specific.

controller <name>

Create a skeleton controller, view and style.

jmk

Creates alloy.jmk.

model <name> <adapter> [schema]

Creates a model with the specified name. See Model Format below.

migration <model_name>

Creates a skeleton migration file for the specified model.

style <<name> | --all>

Creates a skeleton style file with the specified name.
If the name is associated with a view-controller, Alloy uses the id and class names from the markup file to populate the style file.
If --all flag is specified, Alloy generates skeleton style files for all view-controllers.
If you add new id or class attributes to the markup file, running this command updates the style file with the new attributes.

view <name>

Creates a skeleton view and style with the specified name.

widget <name>

Creates a basic widget with the specified name.

-o, --outputPath <outputPath>

Output path for generated code. Point to the 'app' directory.

--platform <platform>

Create a platform-specific view or controller component, where <platform> is either android, ios or mobileweb.

-f, --force

Forces the command to execute.

-n, --no-colors

Disables color output.

Model Format

To generate a model, first select the adapter type:

  • 'sql' for the SQLite database for the Android and iOS platform.

  • 'localStorage' for HTML5 localStorage for the Mobile Web platform.

  • 'properties' for storing models locally in Titanium SDK context.

For the 'sql' and 'properties' adapters, you will also need to specify a table schema. The 'sql' adapter type will also generate a migration file with the model.

The table schema format for generating models is a space-delimited list of the field name, followed by a colon (':'), followed by the data type. For example, specifying 'name:string age:number sex:varchar dob:date' will create a table with four columns: 'name' which stores a string, 'age' which stores a number, 'sex' which stores a character, and 'dob' which stores a date.

Actually, in the above example, since both the Android and iOS platforms use SQLite, none of these datatypes are available. Instead, they will be mapped based on the following:

Datatype

SQLite Datatype

string
varchar
text

TEXT

int
tinyint
smallint
bigint
integer

INTEGER

double
float
real

REAL

blob

BLOB

decimal
number
date
datetime
boolean

NUMERIC

null

NULL

unknown datatype

TEXT

Install

Installs special Alloy project components.

alloy install <module> [<project_path>]

Options

Description

<module>

Format is module specific.

plugin

Installs the compiler plugin to hook the Alloy project to Studio.

<project_path>

Path to the Alloy project, otherwise the current working directory is used.

Compile

Compiles Alloy code to Titanium SDK code.

alloy compile [<project_path>] [--config <compiler_options>] [--no-colors]

Options

Description

<project_path>

Path to the Alloy project, otherwise the current working directory is used.

-c, --config <compiler_options>

Compiler configuration options to use. See Compiler Options below.

-n, --no-colors

Disables color output.

Compiler Options

The compiler options are a list of comma-delimited assignment statements (variable=value) without any spaces. For example, specifying "beautify=false,deploytype=test" overrides the default compiler behavior to disable beautifying the generated JavaScript files and building the application for the test environment.

Refer to the event.alloyConfig object in Build Configuration File (alloy.jmk) for a list of settable compiler options.

Run

Use the titanium build command to run Alloy projects. See the Titanium Command-Line Interface Reference guide for more information.

il8n-extract

Inspects your TSS and JS files for instances of Titanium's localization functions, extracts the il8n key from each function and adds it to the target language's strings.xml file.

alloy extract-il8n [<language>] [--apply]

Options

Description

<language>

Optional. A two-letter language code that specifies the target language. Default is en (English).

--apply

Optional. If present, the command writes new localization entries to the target language's strings.xml file. If absent, a preview of the changes are displayed in the terminal window.

The following localization functions are supported:

The syntax options for calling alloy extract-i18n are shown below.

// Show a before and after of your i18n file. Does NOT write changes to the file.
alloy extract-i18n  
 
// Write changes to "i18n/en/strings.xml":
alloy extract-i18n --apply   
 
// Specify "es" as the language and write the changes to "i18n/es/strings.xml":
alloy extract-i18n es --apply
 
// Specify a different language ("es") and preview changes:
alloy extract-i18n es

Also see Extracting localization strings in the Alloy Tasks with the CLI guide.

Additional Options

Options

Description

-h, --help

Outputs command usage.

-v, --version

Outputs the version number.