The otter command
One launcher runs programs, checks them, manages projects, and compiles web applications.
Commands
PowerShell
otter # start the interactive REPL
otter <file.ot> # run a program (shortest form)
otter run <file.ot|project> # run a program or project
otter check <file.ot|project> # validate without running
otter test [target] # run tests in a project or test file
otter build [target] # build a project into dist/
otter publish [target] # package a project into publish/
otter new <type> <name> # create a project: console, desktop, web, automation, game
otter web <file.ot|project> # compile to a web application and open it
otter serve <file.ot> [-Port N] # run a web server program
otter desktop <file.ot> # run a desktop app with the system bridge
otter help # show help
otter --version # show the version
Running programs
otter run hello.ot and otter hello.ot do the same thing. The words after the file name are passed to the program in its built-in arguments list, except the flags Otter itself uses (listed below):
Otter
say "Arguments received:" length of arguments
each arg in arguments
say " Arg:" arg
.
Running otter run script.ot deploy staging prints Arguments received: 2, then each argument on its own line.
Otter reads its own flags first, and they never reach the program: -Port, -NoOpen, -Open, -ParseOnly, -DebugTokens, -DebugAst, -DebugErrors, -Breakpoints, -h, -help, --help, -v, -version and --version (for example, otter run script.ot --help shows Otter's help instead of running the program). Short flags that could be the start of more than one PowerShell parameter name, such as -p, -e, -i, -w, -D and -Out, stop with an error saying the parameter name is ambiguous. -- is not an escape and also stops with that error. Plain words and double-dash options such as --name=bob or --port 8080 are passed through unchanged.
Checking without running
otter check parses a program, or a project's entry point and the files it imports with use, and reports the first problems it finds. Other .ot files in a project, including its tests, are not checked. Nothing is executed and no files are touched, so it is safe on any file, and it suits editors and automated checks.
Web applications
PowerShell
otter web app.ot # compile and open in your browser
otter web app.ot -NoOpen # compile only; writes app.html next to the source
Options
Otter
-NoOpen with otter web: write the HTML but do not open a browser
-Port <n> with otter serve: the port to listen on
-ParseOnly check that a file is well formed and stop
-DebugTokens print the tokens the lexer produced (for people working on Otter)
-DebugAst print the syntax tree the parser produced
-DebugErrors show the underlying PowerShell error instead of the friendly one
Exit codes
Scripts and automated checks can rely on these to tell why otter stopped:
Output
0 success
1 usage error: unknown command, missing argument, file not found, wrong extension
2 the source does not parse (a syntax problem)
3 a well-formed program failed while running
Configuration
Otter has no global configuration file. A project is configured by its otter.json manifest (see Projects). The one environment variable Otter reads is OTTER_BROWSER_USER_DATA_DIR, which chooses the browser profile folder used by otter desktop.
If otter is not recognized, open a new terminal so it picks up the PATH, or run the launcher by its path. See Troubleshooting.
Projects
Troubleshooting