acton fmt
Reference manual for the acton fmt command
Synopsis
acton fmt [options] [paths...]
Description
Format .tolk files using the built-in Tolk formatter.
The command can rewrite files in place or run in --check mode for CI and
pre-commit validation. If no _paths_ are provided, Acton scans the resolved
project root recursively.
Options
Format Options
Files or directories to format.
Acton scans the project root.
Check formatting without rewriting files.
In this mode Acton prints diffs for mismatches and exits non-zero.
Display Options
Control when to use colored output.
auto, always, never
Project Options
Path to the Acton.toml file to use for this invocation.
Use this when running the command outside the project directory or when the manifest lives at a non-default location.
Path to the project root to use for configuration discovery and relative defaults.
This conflicts with --manifest-path.
Behavior
- Only
.tolkfiles are formatted - Directory traversal is recursive
- Built-in ignore globs always apply, including
node_modules,.git,target, and.acton - explicit file arguments are formatted even if they would match
[fmt].ignore - directory traversal applies
[fmt].ignoreand built-in excludes to relative and absolute paths - Syntax errors are reported as diagnostics and cause a non-zero exit
--checkprints a unified diff with three lines of context for each changed file
Configuration
acton fmt reads defaults from [fmt] in Acton.toml:
[fmt]
width = 100
ignore = ["contracts/generated/*.tolk"]
separate-import-groups = trueUseful fields include:
widthfor maximum formatted line widthignorefor additional exclude globsseparate-import-groupsfor blank lines between import groups
Import Sorting
Imports are sorted by group in this order:
@stdlib@acton- other
@...imports - plain imports
./...../...
Within each group, imports are sorted lexicographically.
Exit Status
0: All requested files were formatted successfully, or--checkfound no formatting differences.1: Files needed formatting in--checkmode, syntax errors prevented formatting, or path resolution failed.
Examples
-
Format all Tolk files in the project:
acton fmt -
Format selected paths:
acton fmt contracts scripts/deploy.tolk -
Validate formatting without writing files:
acton fmt --check -
Run against another project root:
acton --project-root ../my-project fmt --check -
Check import grouping after enabling blank lines between groups:
acton fmt contracts/main.tolk --check
See Also
acton help check- Formatting guide
Last updated on