Everyday commands
The commands you use all the time. check, build, run, fmt and watch, their options, and what strict checking adds.
This page goes through the commands you use every day. It uses the shapes
project from Projects and modules. Run the
commands in the project folder, next to Actus.toml.
| Command | What it does |
|---|---|
actus check | reads the program and reports mistakes. Builds nothing. |
actus build | compiles the program to an object file or an executable. |
actus run | builds the program, runs it once, and removes the executable. |
actus test | runs your tests. See Testing. |
actus fmt | puts your code in the standard layout. |
actus watch | checks again every time a file changes. |
actus lock | updates Actus.lock. See Projects and modules. |
actus explain | tells you what an error code means. See Fixing and explaining errors. |
actus fix | applies the fixes that the compiler is sure about. See Fixing and explaining errors. |
actus lsp | starts the language server for editors. See Editor support. |
actus mcp | starts the compiler server for assistants. See Using Actus with AI assistants. |
Every command prints actus <command> --help with its options.
The version
The first line is the version of Actus. The host line is your system. The
backends line lists the code generators this copy of Actus has. Put these
lines in a bug report.
To see only the first line, send the output through head:
head closes the pipe after the first line, and actus stops without an
error message. The same is true for the other commands, so a pipe such as
actus test --list | head -3 is safe to use.
check
actus check is the fastest way to find out whether your code is correct. It
reads the program, checks names, types and ownership, and stops there.
When an error has a code, actus explain E#### tells you more about it, and
actus fix can apply the fix when the compiler knows one that is safe. See
Fixing and explaining errors.
actus check starts at src/main.act and follows the import lines. A file
that nothing imports is not checked. To check one file, give its path. Say
that src/extra.act holds a verb whose parameter has no role,
verb helper(x) {, and a closing brace:
The command exits with status 1 when it finds an error.
build
actus build compiles the program. Without options it stops early and only
writes an object file. To get a program you can run, add --emit exe:
Everything the compiler writes goes into the capsula folder, in a folder
for the profile and one for your system. You can delete capsula at any
time. These options change what build does:
| Option | Effect |
|---|---|
--emit obj | write an object file. This is the default. |
--emit exe | link an executable. It needs what Install describes: a C compiler on Linux and macOS, the Build Tools for Visual Studio on Windows. |
--release | the release profile |
--profile <name> | the profile debug, release or size |
--backend llvm|cranelift | the code generator. llvm is the default. |
-o <output> | where to write the result |
--strict | use the strict rules, see Strict checking |
[file.act] | build this file instead of the project |
The three profiles ask the compiler for different things:
debugis the default. It does not optimize, so it builds fastest.releaseoptimizes for speed.sizeoptimizes for small code.
You can set a default profile in Actus.toml with profile = "release"
under [build]. An option on the command line wins over the file. Giving
both --release and --profile is an error.
LLVM is the default backend and the one to use. --backend cranelift selects
the other code generator that the compiler contains. A backend that is not
available is an error. Actus never switches to the other one by itself.
An option that Actus does not know is reported before anything is built.
This is true for every command, not only build. The command exits with
status 2:
A value that Actus does not know is reported in the same way:
run
actus run builds the program, runs it, and removes the temporary
executable. It takes --release, --profile and --backend like build.
The last line comes from actus run. When your program exits with a status
that is not 0, actus run exits with the same status.
Pass arguments to your program
Everything after -- goes to your program, not to actus. A program reads
its arguments with std::process. This one prints each argument, except the
first one, which is the name of the program itself:
fmt
actus fmt rewrites your files in the standard layout, so that all Actus code
looks the same. Without a path it formats every .act file in src and
tests:
Here every file was tidy already, so the command reports is already formatted
for each one and does not rewrite it. A file that it did change is reported as
formatted with its path, and the last line counts both kinds. For example,
after one file was untidy, the end of the output is
formatted 1 file, 6 already formatted.
To only check, add --check. Nothing is written, and the
exit status is 1 if a file needs formatting:
A file that needs formatting is reported as is not formatted. Use
actus fmt --check in a script or a CI job to keep a project tidy.
To format one file, give its path. actus fmt takes a file, not a folder:
The formatter keeps lines at 100 columns or less. It wraps a long
documentation block, so that the text sits on lines of its own between the
""" marks, and it breaks a long expression before an operator. This
program has a sum on one long line:
For the file that it changed, the command prints:
The file now reads:
The formatter also puts several import lines into one block and adds a
blank line between the open lines of a facade. A file with a syntax error
cannot be formatted, and the command prints the error.
watch
actus watch checks the project, then waits. Whenever a source file changes,
it checks again. Leave it running in a second terminal while you edit:
Now change erg height = 7; to erg height: Int = "seven"; and save. The
screen is cleared and the new result appears:
Put the line back and save again. The screen is cleared once more:
Press Ctrl-C to stop it. It also notices changes in the other files of the
project, not only in main.act. These options change it:
| Option | Effect |
|---|---|
--once | check one time and exit. The status is 1 if there are errors. |
--build | build the executable after each change, not only check |
--interval <ms> | how often to look for changes, in milliseconds |
--release, --profile <name> | the profile used with --build |
Strict checking
--strict makes check, build and test stricter. Use it before you share
a project, and in a CI job. It does not change what a correct program does.
Add it to the command, as in actus check --strict. Run it on the shapes
project:
The shapes project does not pass yet. Strict mode wants a documentation
block on every verb, whether it is open or private, and on every open
line of a facade. It checks every file of the project, also a file that
nothing imports. A documentation block is text between """ marks, on the
lines just above the declaration. It must not be empty. Here is the facade,
src/geometry/geometry.act:
And src/geometry/rect.act:
Write a block for doubled in src/geometry/helpers.act and for main in
src/main.act in the same way. Say what the verb is for, and add its roles,
its result and its errors when they matter:
Then the command passes, and the last line says so:
run, fmt and watch do not take --strict. They report it as an unknown
option and exit with status 2:
Strict mode also applies size limits. They count only lines with code. Blank
lines, # comments and documentation blocks do not count, so a full
description never makes a file too long. Strict mode reports the highest limit
that a verb or a file goes over, as an error, and the command stops with
status 1:
| What | Preferred limit | Must be split | Hard limit |
|---|---|---|---|
| One verb | above 50 lines (E1853) | from 60 lines (E1854) | above 80 lines (E1855) |
| One file | above 500 lines (E1850) | from 600 lines (E1851) | above 800 lines (E1852) |
Normal mode does not look at the size. For example, a documented main with
59 lines of code is over the preferred limit:
A verb with 69 lines must be split, and one with 89 lines is over the hard limit:
A file that is too long gets the same kind of message, for example
source file has 506 code lines; preferred limit is 500. The usual fix is to split the verb or the file into smaller parts.
If you want to turn the limits off for a project, set source_limits = "limitless" under [package] in
Actus.toml, and run actus lock, because the lock file records the setting.
What you learned
actus checkfinds mistakes without building. It only follows the imports fromsrc/main.act, unless you give it a file.actus buildwrites an object file by default. Add--emit exefor a program, and--releaseor--profile sizefor another profile.actus runbuilds and runs once. Arguments for your program go after--.actus fmtformats,actus fmt --checkonly checks and exits with 1 when a file needs formatting.actus watchchecks again after every change.--strictasks for a documentation block on every verb and applies size limits. Use it withcheck,buildandtest.actus explain E####explains an error code, andactus fixapplies the safe fixes.
Next: Editor support.