The command line
Two commands come with @ambers/cli: amber and amberc. Two grunt tasks come with @ambers/sdk: amberc and amdconfig. This page lists what each takes. The build page shows them at work.
amber
amber with no arguments prints its versions and the commands it knows:
Welcome to Amber CLI version 0.108.5 (Amber 0.32.0, NodeJS 24.18.0).
Available commands
config
help
init
repl
serve
version
| Command | What it does |
|---|---|
amber init |
Generates a project in the current directory, which must be empty. It runs grunt-init with Amber’s template, asks its questions, and then runs npm run init, which is npm install and grunt default devel. |
amber serve |
Serves the current directory over HTTP and accepts the files Helios commits. Options below. |
amber config |
Writes config.js for the current directory, as the amdconfig grunt task does, without grunt. |
amber repl |
Opens a read-eval-print loop on Amber under Node.js. |
amber version, amber help |
Print the versions, and the list above. |
amber serve
The server serves files from its directory and writes a file when Helios commits a package. The welcome line names the port: Starting file server on http://127.0.0.1:4000. Each option takes a value:
| Option | Default | What it does |
|---|---|---|
--port |
4000 |
The port to listen on. |
--host |
127.0.0.1 |
The address to listen on. 0.0.0.0 opens the server to other machines. |
--base-path |
the current directory | The directory to serve. Commits are written under it too. |
--fallback-page |
none | A file to serve for every path that is not a file, for an application with its own routing. |
--username, --password |
none | Ask for these with basic authentication. |
The server warns when the directory has no index.html. There is no --help: that line starts a server too. The options are also the way the server is scripted; FileServer createServerWithArguments: takes the same list.
amber repl
The REPL evaluates a line as a workspace does. The result of an expression is kept in a variable named res1, res2 and so on, and printed with its class:
Type :q to exit.
amber >> 3 + 4
res1: Number = 7
amber >> x := res1 * 6
x: Number = 42
amber >> :q
An assignment keeps its own name. :q quits. The REPL runs Amber’s kernel with the compiler, not your project; it is for trying the language.
amberc
amberc compiles .st files to .js files from the command line, without grunt. Its usage line is:
amberc [-C configFile | -p mapping1,mapping2...] [-l lib1,lib2...] [-g jsGlobal1,jsGlobal2]
[-n namespace] [-D output_dir] [-r module1,module2] [-v] file1 file2 ...
| Option | What it does |
|---|---|
-C config.js |
Read the loader configuration of a project, so that libraries are found where grunt finds them. |
-p amd:path,... |
Map namespaces to directories by hand, when there is no config.js. |
-l lib1,lib2 |
Load these modules before compiling, so that the compiler knows their classes. The Gruntfile’s libraries. |
-g name1,name2 |
Accept these JavaScript globals in the sources, as window and document are accepted. |
-n namespace |
The namespace the compiled packages export under. The Gruntfile’s amd_namespace. |
-D directory |
Write the .js files here instead of beside their sources. |
-r module1,module2 |
Load these Node.js modules first, for a polyfill the compiler needs. |
-v |
Say what it does. |
Each file holds one package, named as the file. In a project, this compiles one package the way grunt compiles them all:
amberc -C config.js -l amber/web/Web,silk/Silk -n amber-helloamber src/HelloAmber.st
One difference: amberc compiles with the Amber that came with @ambers/cli, and reads the project’s config.js only to find the libraries. grunt compiles with the project’s own @ambers/lang.
The grunt tasks
grunt.loadNpmTasks('@ambers/sdk') in a Gruntfile makes two tasks available.
amberc compiles a list of .st files. The task has three options. amber_dir is the directory of @ambers/lang, and is required. configFile is the loader configuration to read, and verbose makes it say more. Each target has src, the files in dependency order. It may have libraries, amd_namespace, jsGlobals and output_dir, with the meanings of the amberc options above. The generated Gruntfile points amber_dir at node_modules/@ambers/lang and configFile at config.js.
amdconfig writes the loader configuration. Its target names the file to write, dest: 'config.js'. Its option root_dir says where to look for .amd.json files, the current directory by default. The task finds every .amd.json under that directory, the project’s own and those in node_modules, and writes one require.config call. The libraries page says what the files hold.