REPL for Titanium. Inspired heavily by node.js's own repl.
- Full access to Titanium API, including tab completion for Titanium namespaces
- Command history (↑,↓)
- Save and load REPL sessions
- Add files and native Titanium modules to REPL
require()
commonjs modules at runtime straight from the filesystem- Multi-line statements
- Color-coded return values, by type
- Much more coming (see enhancements)
$ npm install -g triple
≫ triple -h
Usage: triple [options] [file [delay]]
Options:
-h, --help output usage information
-V, --version output the version number
-m, --module <ids> Add native module(s) to REPL
-I, --ios-version <iosVersion> select the ios version to use
-v, --verbose Enable verbose output
Examples:
basic REPL
$ triple
[creating app]
[loading app]
> alert('hello, world!');
load by file or url, with optional delay between lines
$ triple /path/to/file.js
$ triple http://bit.ly/1zc7Nvo
$ triple /path/to/file.js 2000
add native module(s) to REPL by id
$ triple --module ti.paint
$ triple --module some.module,another.module
triple includes a few commands to control its operations. These must be preceded by the dot (.) to be recognized as commands.
Add file(s) to REPL at runtime.
$ triple
> .add /path/to/image.png
> var image = Ti.UI.createImageView({image:'image.png'});
Abort a multi-line statement.
$ triple
> for (var i = 0; i < 100; i++) {
... // i want to stop this statement
... .break
>
Create a new execution context for the current REPL.
$ triple
> var foo = 123;
undefined
> foo
123
> .clear
> foo
ReferenceError: Can't find variable: foo
>
Exits the REPL.
$ triple
> .exit
$
Shows command help in the REPL.
Load a local or remote Javascript file line by line in to the REPL. A delay
between each line of code's execution can be specified in milliseconds. If <file>
is a directory, triple will attempt to load app.js
then index.js
from the directory.
$ triple
> .load ./app.js
> .load http://bit.ly/1zc7Nvo
> .load http://bit.ly/1zc7Nvo 2000
Saves the current REPL session to a file. This file can be loaded in triple later with .load
.
$ triple
> Ti.UI.createWindow({backgroundColor:'#a00'}).open();
undefined
> .save ./test.js
The following is the only configuration for which this has been tested so far:
- Mac OSX 10.9.4+
- iOS 7.1+ simulator
- Titanium SDK 3.2.3+
Support for all of Appcelerator's supported platforms is planned. Windows OS support is planned as well.
Basic Android support is available (--plaform android
). Currently all of triple's features are being implemented and/or tested against Android. Check issue#10 for details.
Aside from the issues in this repo, here's some other known issues with Titanium that you might encounter when using triple.
- [TIMOB-17449] - iOS: this.Kroll cannot be inspected, and throws errors when you try
- [
TIMOB-17448] - iOS: error when commonjs module exports certain types (anything other than function, object, or string). Fixed in Titanium 3.4.0.