Projects
A project is a folder with an otter.json manifest. Otter can create one, check it, test it, run it, build it and package it.
Create a project
PowerShell
otter new console my-app
Output
Created new Otter console project in "C:\Users\you\my-app".
To get started:
cd my-app
otter check .
otter test .
otter run .
The type is one of console, desktop, web, automation or game. A new console project contains:
Output
my-app/
main.ot the entry point
otter.json the project manifest
src/ your own modules
assets/ files the project ships with
tests/app_test.ot a starter test
The manifest
Otter
{
"name": "my-app",
"version": "0.1.0",
"archetype": "console",
"target": "console",
"entryPoint": "main.ot",
"assets": [],
"build": { "outputDir": "dist", "clean": true },
"scripts": {
"start": "otter run .",
"test": "otter test .",
"check": "otter check ."
}
}
otter.json is the Otter 1.0 manifest. An older project.json is read only when a folder has no otter.json; when both exist, otter.json wins. entryPoint and every asset must stay inside the project folder, and publishing needs a name and a plain version string such as 1.2.0. The project manifest specification lists every field, its type and default, and which commands use it.
Project manifest specification
Work with it
PowerShell
otter check . # validate the entry point and the files it uses
otter test . # run every test under tests/
otter run . # run the entry point
otter build . # build into dist/
otter publish . # package into publish/ as a zip with a SHA-256 checksum
Output
Running 1 Otter test...
PASS tests/app_test.ot
1 passed
otter check . checks the entry point and every file it imports with use. Other .ot files in the project, including the tests, are not checked; otter test . runs the tests.
Web and game projects run in a browser: use otter web . for them, and otter run . for console and automation projects. Keep a web project's entry point at the project root, because relative paths to images and other assets break after otter build when the entry point is in a subfolder (to be fixed after 1.0). The one stylesheet rule is a .css file named after the entry point, beside it: main.css for main.ot. otter web, otter build and otter publish include it in the page.
Writing a test
A test is an ordinary Otter file. It passes when it finishes and fails when it calls fail with:
Otter
score is 100
if score is not 100
fail with "Expected score to be 100."
.
say "All checks passed"
Build and publish
otter build checks the project and writes a runnable copy into dist/. otter publish builds it, packages the files into publish/<name>-<version>.zip, computes the SHA-256 checksum, and verifies the package.
The otter command
Modules